Jump to content

[C++] Automatic Mouse Macro

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
Before hand just know this is one of the original versions of the program.
The version I am working on now is a lot more user friendly and will have the ability to copy keys pressed also.

I just wanted to show something..



//Execute program than click in destined location.

//Press  space bar to replay these clicks.

//Remember this == beta I am aware of lots of the problems lol

//Have fun

//Head over to logickills.org for newer versions of all my code

//LogicKills;


#include <iostream>

#include <windows.h>

#include <vector>

 

using namespace std;

     

int main()

{ 

   //Vectors were used so number of clicks didn't have to be known

   vector<int>xary; 

   vector<int>yary;

    

      

    int clicks = 0;

    int index = 0; 

    //Do nothing until [SPACE] bar is pressed

    while(!GetAsyncKeyState(VK_SPACE))

    {

        /* This is the heart of the program. It waits for the user to 

            click the mouse then records the information in the associated

            vector.

        */

      

        if (GetAsyncKeyState(VK_LBUTTON)){

        Sleep(150);  

         POINT cursorPos; 

        GetCursorPos(&cursorPos);

        xary.push_back(cursorPos.x);      

        yary.push_back(cursorPos.y); 

        ++index;  

        ++clicks;

        } 

        }

        

    /     

    /* DEBUG CODE

    cout << xary[0] << " " << yary[0];

    cout << "\n";

    cout << xary[1] << " " << yary[1];

    */

    

    for (int i = 0; i < xary.size(); i++) //xary will always be == to yary in size

    { 

       

        Sleep(10);

        SetCursorPos(xary[i],yary[i]);

        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

 

} 

    //cin.get();

    return 0;

}

    

http://logickills.org
Science - Math - Hacking - Tech

#2
whitey6993

whitey6993

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 437 posts
Cool example, would like to see more of this program :)