Use a VK_Packet as a Hotkey
-
- Posts: 3
- Joined: 24 Jul 2021, 02:04
Use a VK_Packet as a Hotkey
Is it possible for AutoHotkey to detect a VK_Packet as a hotkey? I'm using Microsoft's remote desktop app to connect to my pc from my iPad, but for some reason they decided to send all iPad keyboard inputs as Unicode via VK_packets. This makes it so keyboard shortcuts don't always work the way they should. So can I use AutoHotkey to detect these vk_packets and output normal keystrokes?
Re: Use a VK_Packet as a Hotkey
I suppose that iPad keyboard layouts and Windows keyboard layouts do not correspond, so it makes sense for the app to pass through the actual characters that you enter rather than trying to map them to virtual keycodes that will then map back to characters.
A hotkey must consist of optional modifiers plus a single "suffix" key which can be identified by VK (in the range 0x01-0xFF) or SC (in the range 0x001-0x1FF) - not both. VK_PACKET events all have the same VK value (VK_PACKET) and have a character code in place of an actual scancode. They cannot be handled as hotkeys.
You may try a hotstring of the form :*?:●::, replacing ● with the character you want to detect. However, this allows the character to reach the active window, then tries to delete it with backspace.
To both suppress and capture VK_PACKET events while ignoring other types of character input, you may use InputHook. The following should show a single MsgBox with "☺".
It's unclear to me how you would activate key combinations via the iPad app, but I suppose the following might be sufficient:
This code should be used standalone or placed in the auto-execute section.
A hotkey must consist of optional modifiers plus a single "suffix" key which can be identified by VK (in the range 0x01-0xFF) or SC (in the range 0x001-0x1FF) - not both. VK_PACKET events all have the same VK value (VK_PACKET) and have a character code in place of an actual scancode. They cannot be handled as hotkeys.
You may try a hotstring of the form :*?:●::, replacing ● with the character you want to detect. However, this allows the character to reach the active window, then tries to delete it with backspace.
To both suppress and capture VK_PACKET events while ignoring other types of character input, you may use InputHook. The following should show a single MsgBox with "☺".
Code: Select all
ih := InputHook("L0 V") ; No collection buffer, visible input.
ih.KeyOpt("{All}", "I") ; Ignore character input from all keys.
; VK_PACKET events are treated as having scancode=0. In current versions,
; the 'I' option must be cleared from both vkE7 and sc000 for VK_PACKET.
ih.KeyOpt("{vkE7}{sc000}", "-I")
ih.KeyOpt("{vkE7}", "S") ; Suppress VK_PACKET events. To not suppress, remove this line.
ih.OnChar := Func("OnPacket")
ih.Start()
OnPacket(ih, char) {
MsgBox % char
}
Send {U+263A}
Sleep 1000
ExitApp
Code: Select all
ih := InputHook("L0 V I2") ; No collection buffer, visible input, ignore SendLevel<2.
ih.KeyOpt("{All}", "I") ; Ignore character input from all keys.
; VK_PACKET events are treated as having scancode=0. In current versions,
; the 'I' option must be cleared from both vkE7 and sc000 for VK_PACKET.
ih.KeyOpt("{vkE7}{sc000}", "-I")
ih.KeyOpt("{vkE7}", "S") ; Suppress VK_PACKET events.
ih.OnChar := Func("OnPacket")
ih.Start()
OnPacket(ih, char) {
SendLevel 1
Send {Blind}{Raw}%char%
}
Re: Use a VK_Packet as a Hotkey
Code: Select all
vkE7::ToolTip % A_ThisHotkey
Code: Select all
OnMessage(WM_KEYDOWN := 0x0100, Func("WM_KEYDOWN"))
WM_KEYDOWN(wParam, lParam, msg, hwnd) {
switch wParam
{
case 0xE7: ; VK_PACKET
ToolTip % A_ThisFunc
}
}
-
- Posts: 3
- Joined: 24 Jul 2021, 02:04
Re: Use a VK_Packet as a Hotkey
Thank you so much, Lexikos, that second one worked perfectly! Now I can video edit or use Blender from my iPad with Microsoft Remote Desktop! Hooray!
-
- Posts: 3
- Joined: 24 Jul 2021, 02:04
Re: Use a VK_Packet as a Hotkey
I just realized that the code I used before still has one issue: holding down a key on the ipad does not register as holding down a key on the computer. Is there a way to solve this too? Thanks!
Who is online
Users browsing this forum: Google [Bot] and 64 guests