Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define WINVER 0x0500
- #include <windows.h>
- using namespace std;
- // Forward declaration of the LeftClick function
- void LeftClick ( );
- // Forward declaration of the MouseMove function
- void MouseMove ( int x, int y );
- int main()
- {
- Sleep(5000);
- MouseMove(300, 300);
- LeftClick();
- return 0;
- }
- // LeftClick function
- void LeftClick ()
- {
- INPUT Input = {};
- // left down
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
- ::SendInput(1,&Input,sizeof(INPUT));
- // left up
- ::ZeroMemory(&Input,sizeof(INPUT));/*
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
- ::SendInput(1,&Input,sizeof(INPUT));//*/
- }
- // MouseMove function
- void MouseMove (int x, int y )
- {
- double fScreenWidth = ::GetSystemMetrics( SM_CXSCREEN )-1;
- double fScreenHeight = ::GetSystemMetrics( SM_CYSCREEN )-1;
- double fx = x*(65535.0f/fScreenWidth);
- double fy = y*(65535.0f/fScreenHeight);
- INPUT Input= {0};
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
- Input.mi.dx = fx;
- Input.mi.dy = fy;
- ::SendInput(1,&Input,sizeof(INPUT));
- }
Add Comment
Please, Sign In to add comment