Bind commands to key-up and key-down in AutoHotkey
You could compile your .ahk scripts as .exe. Then have
Pause::C:\fun1.exe
Pause Up::C:\fun2.exe
More info on .akh to .exe: autohotkey- ahk2exe
You can accomplish the desired functionality with this code:
pause::
fun1()
keyWait, pause
fun2()
return
If you are dealing with subroutines instead, use this:
pause::
gosub, sub1
keyWait, pause
gosub, sub2
return