more control keys, and VkKeyScanW -> VkKeyScanExW with forground window
keyboard layout
This commit is contained in:
parent
8ea5d80f01
commit
3aebc43111
2 changed files with 10 additions and 1 deletions
|
|
@ -350,7 +350,10 @@ impl Enigo {
|
|||
// NOTE VkKeyScanW uses the current keyboard layout
|
||||
// to specify a layout use VkKeyScanExW and GetKeyboardLayout
|
||||
// or load one with LoadKeyboardLayoutW
|
||||
let keycode_and_shiftstate = unsafe { VkKeyScanW(chr as _) };
|
||||
let current_window_thread_id =
|
||||
unsafe { GetWindowThreadProcessId(GetForegroundWindow(), std::ptr::null_mut()) };
|
||||
let layout = unsafe { GetKeyboardLayout(current_window_thread_id) };
|
||||
let keycode_and_shiftstate = unsafe { VkKeyScanExW(chr as _, layout) };
|
||||
keycode_and_shiftstate as _
|
||||
} else {
|
||||
0
|
||||
|
|
|
|||
|
|
@ -323,6 +323,12 @@ impl Handler {
|
|||
Key::CapsLock | Key::NumLock | Key::ScrollLock => {
|
||||
return;
|
||||
}
|
||||
Key::Home => Some(ControlKey::Home),
|
||||
Key::End => Some(ControlKey::End),
|
||||
Key::Insert => Some(ControlKey::Insert),
|
||||
Key::PageUp => Some(ControlKey::PageUp),
|
||||
Key::PageDown => Some(ControlKey::PageDown),
|
||||
Key::Pause => Some(ControlKey::Pause),
|
||||
_ => None,
|
||||
};
|
||||
let mut key_event = KeyEvent::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue