Results 1 to 5 of 5

Thread: Pretty confusing

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    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(hWndTIMER_CLICK,1000NULL);
                }

                        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_LEFTDOWNpt2.xpt2.y0,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_LEFTDOWN00,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?
    Baaaaaaaaah

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    How is pt1 declared?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    It's declared as a
    POINT pt1;
    Baaaaaaaaah

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    It's kinda due tomorrow so maybe I can get some credits if I finish this...
    Baaaaaaaaah

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width