-
Pretty confusing
I have 2 timers running. One of them is always running and other one is started by the first one when hit F2. Here is the code first:
PHP Code:
case WM_TIMER:
switch(wParam)
{
case TIMER_CHECKMOUSEPOS:
if(GetAsyncKeyState(VK_F2) != 0)
{
MessageBox(NULL,"The cursor position has been recognized. Now move your mouse over an empty place in Runescape and hit 'F9'", "Completed", MB_OK);
GetCursorPos(&pt1);
// itoa(pt1.x,buffer,10);
// MessageBox(NULL,buffer,"DSF",MB_OK);
Counter = 0;
KillTimer(hWnd,TIMER_CLICK);
}
if(GetAsyncKeyState(VK_F7) != 0)
{
MessageBox(NULL,"Starting the clicking loop", "Starting to click", MB_OK);
Counter = 0;
SetCursorPos(pt1.x,pt1.y);
KillTimer(hWnd,TIMER_CLICK);
SetTimer(hWnd, TIMER_CLICK,1000, NULL);
}
if(GetAsyncKeyState(VK_F8) != 0)
{
MessageBox(NULL,"Ended the clicking loop", "Ended clicking", MB_OK);
KillTimer(hWnd,TIMER_CLICK);
}
break;
case TIMER_CLICK:
if (Counter >= 300000)
{
SetCursorPos(pt2.x,pt2.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, pt2.x, pt2.y, 0,0);
SetCursorPos(pt1.x,pt1.y);
Counter = 0;
}
else
{
itoa(pt1.x,buffer,10);
MessageBox(NULL,buffer,"SDF",MB_OK);
SetCursorPos(pt1.x,pt1.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0 , 0, 0,0);
Counter = Counter + 60000;
}
break;
}
break;
When I look at the cursor's x position in the first timer (TIMER_CHECKMOUSEPOS) when F2 is pressed, it's right and positive. But it's negative in the second timer(TIMER_CLICK) which is invoked by the first timer. Where is it changing and how would I get the actual position that I stored when I pressed F2?
-
-
It's declared as a
POINT pt1;
-
It's kinda due tomorrow so maybe I can get some credits if I finish this...;)
-
It may be too late now (wasn't here, sorry), but you must declare it as static so it's values aren't lost between function calls.
Don't forget, WinProc is called one for each message, no less, no more.