Skip to content

Instantly share code, notes, and snippets.

@rootux
Forked from chuckleplant/MouseControl.h
Created June 24, 2016 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rootux/1dbe06890d2cf3fb1e0c4bcf722968d8 to your computer and use it in GitHub Desktop.
Save rootux/1dbe06890d2cf3fb1e0c4bcf722968d8 to your computer and use it in GitHub Desktop.
Mouse control for Windows in C++. Dependencies: User32 Windows library.
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x500
#endif
#include "Winuser.h"
#include "windef.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);
}
};
@rootux
Copy link
Author

rootux commented Jun 24, 2016

Added missing #include "windef.h" to support POINT type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment