Last active
April 12, 2022 16:39
-
-
Save chuckleplant/8417926 to your computer and use it in GitHub Desktop.
Mouse control for Windows in C++. Dependencies: User32 Windows library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _WIN32_WINNT | |
# define _WIN32_WINNT 0x500 | |
#endif | |
#include "Winuser.h" | |
class ofxMouse | |
{ | |
public: | |
static enum MouseEventFlags | |
{ | |
LeftDown = 0x00000002, | |
LeftUp = 0x00000004, | |
MiddleDown = 0x00000020, | |
MiddleUp = 0x00000040, | |
Move = 0x00000001, | |
Absolute = 0x00008000, | |
RightDown = 0x00000008, | |
RightUp = 0x00000010 | |
}; | |
static void SetCursorPosition(int x, int y){ | |
SetCursorPos(x, y); | |
} | |
static void MouseEvent(MouseEventFlags value){ | |
POINT curPos[2]; | |
GetCursorPos(&curPos[0]); | |
mouse_event( | |
(int)value, | |
curPos->x, | |
curPos->y, | |
0, | |
0); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment