hello all,
I am attempting to write a simple programe that will imitate pressing a button on a third party application. so far i have this:

// astro rocks

BOOL CALLBACK FindButttonPush(HWND hWnd, LPARAM lParam)
	if(GetDlgCtrlID(hWnd) == 1000){
		*(HWND *)lParam = hWnd;
		return FALSE;
	return TRUE;

int click()
    int i;
    HWND hWndManager, hWndClick = NULL;
    hWndManager = FindWindow("SWBF2SERVERMANAGER", NULL);
    if(!hWndManager) return 0;
    EnumChildWindows(hWndManager, FindButttonPush, (LPARAM)&hWndClick);
	if(!hWndClick) return 0;
    SendMessage(hWndClick, BM_CLICK,0,0);
    return 1;

The code compile perfectly. The promlem is that it doesnt do what it is suppose to be doing. it is suppose to press a button in an application but it is also inside a panel.
Any help would be greatly apreciated.

8 Years
Discussion Span
Last Post by aces27

is SWBF2SERVERMANAGER the window class, or the caption/title of the window? Also, are you sure that the ID of the control will always be 1000? I tested the same code, but removed the double exit points and the check for 1000... I made a quick VB program with a button on it, with a caption of: SWBF2SERVERMANAGER, (and changed the FindWindow, so that it searched by caption and not class) and voila.... worked like a charm for me.


Could you please five the entire code.

Purpose , Continuously check for a window lets say "Calculator" to start. In case it starts , press the button 5 among the buttons it has.

Am able to check ,if calculator has started for using findwindow and checking if handle is not zero.
Now how do I check whether the button I want to press is present or not , and press it.

Also additionally is it possible to hide the Command Prompt window , completely , using FreeConsole am able to hide it , but it still pops up for a microsecond period.

Aces J

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.