Using a digital piano as a keyboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mhiekuru
Posts: 3
Joined: 29 Jan 2018, 15:50

Using a digital piano as a keyboard

29 Jan 2018, 16:08

I'm trying to use a digital piano as a keyboard and i found this thread about MIDI input library
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.
but I don't know how to implement it in this case, Where can i add a loop that wont just halt the entire script? or is there a better way of doing this?

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
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Using a digital piano as a keyboard

19 Feb 2018, 08:37

Hi,
Sorry that I can't help you, but it seems you made more progress than I did.
I also downloaded the files midi_in_lib.ahk, midi_in.dll and Midi_test.ahk and put them in 1 folder.
After compiling and launching Midi_test.exe, it says "Cannot load library mini_in.dll"
How did you fix that?
(In case you had this error message.)
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 377 guests