17 bool ex = (vKey > 254) || (vKey == 0);
18 Inp->type = INPUT_KEYBOARD;
19 Inp->ki.wVk = ex ? 0 : vKey;
20 Inp->ki.dwFlags = Flags | (ex ? KEYEVENTF_SCANCODE : 0);
21 Inp->ki.wScan = ex ? MapVirtualKey( vKey, MAPVK_VK_TO_VSC ) : 0;
22 Inp->ki.dwExtraInfo = 0;
30 TRACE(
DP_DEBUG, _T(
"SendKeyInput( %u, %s )\n"), vKey, Flags & KEYEVENTF_KEYUP ?
"KeyUp" :
"KeyDown" );
31 return SendInput( 1, &Inp,
sizeof(INPUT) );
40 return (SendInput( 2, Inp,
sizeof(INPUT) ) == 2);
49 bool kExt,kShift,kCtrl,kAlt;
52 flags = HIBYTE( Hotkey );
55 kCtrl =
bool_cast( flags & HOTKEYF_CONTROL );
56 kShift =
bool_cast( flags & HOTKEYF_SHIFT );
59 kExt = kShift = kCtrl = kAlt =
false;
62 if (kShift) nEvt += 2;
71 if (GetKeyboardState( kbState ))
73 if (kbState[VK_SHIFT] && !kShift)
SendKeyInput( VK_SHIFT, KEYEVENTF_KEYUP );
74 if (kbState[VK_CONTROL] && !kCtrl)
SendKeyInput( VK_CONTROL, KEYEVENTF_KEYUP );
75 if (kbState[VK_MENU] && !kAlt)
SendKeyInput( VK_MENU, KEYEVENTF_KEYUP );
80 memset( Inp,0,
sizeof(Inp) );
86 fext = kExt ? KEYEVENTF_EXTENDEDKEY : 0;
88 MakeKeyInput( &Inp[++ix], LOBYTE( Hotkey ), KEYEVENTF_KEYUP| fext );
90 if (kShift)
MakeKeyInput( &Inp[++ix], VK_SHIFT, KEYEVENTF_KEYUP );
91 if (kCtrl)
MakeKeyInput( &Inp[++ix], VK_CONTROL, KEYEVENTF_KEYUP );
92 if (kAlt)
MakeKeyInput( &Inp[++ix], VK_MENU, KEYEVENTF_KEYUP );
97 nSent = SendInput( nEvt, Inp,
sizeof(INPUT) );
101 return (nSent == nEvt);
110 Inp->type = INPUT_MOUSE;
113 Inp->mi.mouseData = (
DWORD) data;
114 Inp->mi.dwFlags = Flags;
115 Inp->mi.dwExtraInfo = 0;
122 INPUT Inp = { INPUT_MOUSE, {{ dx, dy,
LITERAL(
DWORD, data ), Flags, 0,0 }}};
124 TRACE(
DP_DEBUG, _T(
"SendMouseInput( %i, %i, %i, %#x )\n"), dx, dy, data, Flags );
125 return SendInput( 1, &Inp,
sizeof(INPUT) );
133 bool kLeft, kMid, kRight;
135 kLeft = ((Key &
LBUTTON) != 0);
137 kRight = ((Key &
RBUTTON) != 0);
138 if (!kLeft && !kMid && !kRight)
return false;
141 if (kLeft)
MakeMouseInput( &Inp[nEvt++], 0,0,0, MOUSEEVENTF_LEFTDOWN );
142 if (kMid)
MakeMouseInput( &Inp[nEvt++], 0,0,0, MOUSEEVENTF_MIDDLEDOWN );
147 if (kMid)
MakeMouseInput( &Inp[nEvt++], 0,0,0, MOUSEEVENTF_MIDDLEUP );
148 if (kLeft)
MakeMouseInput( &Inp[nEvt++], 0,0,0, MOUSEEVENTF_LEFTUP );
150 nSent = SendInput( nEvt, Inp,
sizeof(INPUT) );
152 if (nSent != nEvt)
ERROR_TRACE( _T(
"SendMouseClick") );
154 return (nSent == nEvt);
void MakeKeyInput(INPUT *Inp, WORD vKey, DWORD Flags)
UINT SendMouseInput(LONG dx, LONG dy, LONG data, DWORD Flags)
#define ERROR_TRACE(What)
bool SendHotKey(WORD Hotkey)
bool SendMouseClick(MOUSEKEY Key)
bool __forceinline bool_cast(BOOL B52)
void MakeMouseInput(INPUT *Inp, LONG dx, LONG dy, LONG data, DWORD Flags)
Debug and error handling support.
UINT SendKeyInput(WORD vKey, DWORD Flags)
bool SendKeyPress(WORD vKey)