Hello, when using #if or Hotkey, If in combination with a function that sends a key, you get weird stuff being sent.
Code: Select all
#NoEnv
#installkeybdhook
#installmousehook
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#MaxThreadsPerHotkey 2
#KeyHistory 0
ListLines Off
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
fn := Func("notepadActive")
Hotkey, If, % fn
Hotkey, % "$w", % "testbug", % "on"
return
testbug:
while(GetKeyState("w", "p"))
{
sendKey_f("a")
sleep, 10
}
return
sendKey_f(key)
{
global
sendEvent % "{" key "}"
}
notepadActive()
{
return WinActive("ahk_exe notepad++.exe")
}
1. Hold down w
What happens?:
In case it is too small, here is the video: https://i.gyazo.com/ae99696f89f0cc762d24822723b8d47c.mp4
In case that's not enough: Weird stuff is being sent in between the "a"s
I don't know why this happens, but it won't happen if you:
1. Replace the function call with sendEvent
2. Replace the sendEvent inside the function with sendInput (but this gives other issues)
I couldn't test it in ahk_l