uLib
User mode C/C++ extended API library for Win32 programmers.
|
Easy to use keyboard and mouse emulation.
#include <uLib/InputEmu.h>
This module contains API's that simplify the emulation of keyboard and mouse events.
These are useful when creating 'macro' functions, e.g. for automation..
Macros | |
#define | MAKE_HOTKEY(key, flags) (WORD)(((flags) << 8) | key) |
Enumerations | |
enum | MOUSEKEY { LBUTTON = _BV(0), MBUTTON = _BV(1), RBUTTON = _BV(2) } |
Functions | |
void | MakeKeyInput (INPUT *Inp, WORD vKey, DWORD Flags) |
UINT | SendKeyInput (WORD vKey, DWORD Flags=0) |
bool | SendKeyPress (WORD vKey) |
bool | SendHotKey (WORD Hotkey) |
void | MakeMouseInput (INPUT *Inp, LONG dx, LONG dy, LONG data, DWORD Flags) |
UINT | SendMouseInput (LONG dx, LONG dy, LONG data, DWORD Flags) |
bool | SendMouseClick (MOUSEKEY Key) |
#define MAKE_HOTKEY | ( | key, | |
flags | |||
) | (WORD)(((flags) << 8) | key) |
Definition at line 23 of file InputEmu.h.
enum MOUSEKEY |
Key flags for SendMouseClick().
Enumerator | |
---|---|
LBUTTON | Left mouse button. |
MBUTTON | Middle mouse button. |
RBUTTON | Right mouse button. |
Definition at line 76 of file InputEmu.h.
Initialize INPUT for keyboard emulation with SendInput.
If vKey > 254, MapVirtualKey is used to map the scancode to a virtual keycode.
[out] | Inp | Pointer to an INPUT struct to initialize. |
[in] | vKey | Virtual keycode (VK_nn) or scancode (>254) of the key to emulate. |
[in] | Flags | KEYEVENTF_nn flags (KEYEVENTF_SCANCODE is added automatically if vKey > 254). |
Definition at line 15 of file InputEmu.cpp.
Send a single key, press or release.
See MakeKeyInput for parameter explanations.
Note: I seems someone at MS has chosen to reinterpret the meaning of KEYEVENTF_KEYUP
to mean both key down and key up. This can be observed on Windows 7 where apps recieve
two of the specified vKey in a row, when using the normal procedure of sending one INPUT
struct for key down and one for key up.
However, the quirk does not occur for emulated shift keys.. Go figure.
Definition at line 26 of file InputEmu.cpp.
bool SendKeyPress | ( | WORD | vKey | ) |
Send a single key, press and release.
See SendKeyInput() for details.
Definition at line 34 of file InputEmu.cpp.
bool SendHotKey | ( | WORD | Hotkey | ) |
Send a standard ComCtl32 HotKey (press and release).
Definition at line 43 of file InputEmu.cpp.
void MakeMouseInput | ( | INPUT * | Inp, |
LONG | dx, | ||
LONG | dy, | ||
LONG | data, | ||
DWORD | Flags | ||
) |
Initialize INPUT for mouse emulation with SendInput.
[out] | Inp | Pointer to an INPUT struct to initialize. |
[in] | dx,dy | Screen position of the emulated mouse event. |
[in] | data | Dependent on Flags.. E.g wheel movement if Flags contain MOUSEEVENTF_WHEEL. |
[in] | Flags | MOUSEEVENTF_nn flags. |
Definition at line 108 of file InputEmu.cpp.
UINT SendMouseInput | ( | LONG | dx, |
LONG | dy, | ||
LONG | data, | ||
DWORD | Flags | ||
) |
Send a single mouse event.
See MakeMouseInput() for parameter explanations.
See also [MSDN} SendInput().
Definition at line 119 of file InputEmu.cpp.
bool SendMouseClick | ( | MOUSEKEY | Key | ) |
Send a single mouse click/chord (press and release).
Definition at line 128 of file InputEmu.cpp.