Hi,
I´ve got a Problem and I don´t know what is wrong with it.
My code has to start an endless loop to look for a named window.
If the window is there, I want to click.
But it does not do that... the window which has to be closed is still on top...
Please help me for that...
#include <windows.h>
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
POINT p ;
int m1 = 65535 / 480;
int m2 = 65535 / 272;
p.x = 460;
p.y = 255;
int x = m1 * p.x;
int y = m2 * p.y;
HWND hwnd;
/* Always check first if program is already running */
hwnd = FindWindow( NULL, L"Prototype");
if (hwnd)
{
DestroyWindow(hwnd);
}
while(1)
{
hwnd = FindWindow(NULL, L"GoPalSettings_np");
if (hwnd)
{
Sleep(3000);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);
Sleep(100);
mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);
}
else
{
Sleep(5000);
}
}
return 0;
}