mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-29 20:40:12 +08:00
[feat] keyboard control supported on Windows
This commit is contained in:
@@ -51,5 +51,18 @@ int KeyboardCapturer::Hook(OnKeyAction on_key_action, void* user_ptr) {
|
||||
|
||||
int KeyboardCapturer::Unhook() {
|
||||
UnhookWindowsHookEx(keyboard_hook_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
|
||||
INPUT input = {0};
|
||||
input.type = INPUT_KEYBOARD;
|
||||
input.ki.wVk = key_code;
|
||||
|
||||
if (!is_down) {
|
||||
input.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
}
|
||||
SendInput(1, &input, sizeof(INPUT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user