https://autohotkey.com/board/topic/2805 ... t-library/
everything pretty much works as intended except that i wanted it to auto-repeat keys that I mapped while i am holding the specific piano key, just like holding a key physically.
i found in the documentation about the send command that When a key is held down, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). However, a Loop can be used to simulate auto-repeat.
This is the example written in the documentation:
Code: Select all
Loop 20
{
Send {Tab down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
Send {Tab up} ; Release the key.
This is the code I'm working with:
Code: Select all
SendMode Input
SetWorkingDir %A_ScriptDir%
OnExit, sub_exit
if (midi_in_Open(0))
ExitApp
;-------------------- Midi "hotkey" mappings -----------------------
listenNote(60, "note60")
listenNote(62, "note62")
listenNote(63, "note63")
listenNote(64, "note64")
return
;----------------------End of auto execute section--------------------
sub_exit:
midi_in_Close()
ExitApp
;-------------------------Miscellaneous hotkeys-----------------------
Esc::ExitApp
;-------------------------Midi "hotkey" functions---------------------
note60(note, vel)
{
if (vel)
Send {Left down}
else
Send {Left up}
}
note62(note, vel)
{
if (vel)
Send {Down down}
else
Send {Down up}
}
note63(note, vel)
{
if (vel)
Send {Up down}
else
Send {Up up}
}
note64(note, vel)
{
if (vel)
Send {Right down}
else
Send {Right up}
}
;------------------------- Midi input library ----------------------
#include midi_in_lib.ahk