mikeyww wrote: ↑04 Mar 2024, 20:25
Code: Select all
#Requires AutoHotkey v2.0
ih := InputHook('I', 'a{SC34}{F12}')
ih.OnChar := ih_Char
ih.Start(), ih.Wait()
MsgBox 'Done!', 'Status', 'Iconi'
ih_Char(ih, char) {
Static last := ''
If char != last
SendText char
last := char
}
I don't know how to use It.
I want exactly what this function does :
Code: Select all
Wait_one_Key(key, options := "") { ; one key
key_pressed := false
ih := InputHook(options)
; ih.KeyOpt("{All}", "+INS") ; make all keys ignored and visible
ih.KeyOpt("{All}", "N")
ih.MinSendLevel := 1
ih.OnKeyDown := (ih, vk, sc) => (
key_pressed := GetKeyName(Format("vk{:x}sc{:x}", VK, SC)),
sc := Format("sc{:x}", sc),
key_pressed := (key = key_pressed) or (key = sc),
(!key_pressed ? Send('{' sc '}') : 0),
ih.Stop()
)
ih.Start(), ih.Wait() ; start input hook ; wait for input hook to end
return key_pressed
}
The problems in this function are :
1- It Doesn't wait for multiple keys
2- Doesn't accept scan code (SC) or Virtual keycodes (VK).
So the first function works well and I want It to work like this function :
while waiting, I want when pressing any other key different from the listed keys e.g "c" I want it to be sent (written) from the first press no from the second press.
Because now, while waiting, when I press non-listed key e.g "c" nothing happens from the first press But when I press It again (second press) It send "c".