OnlinePianoPlayer for roblox and more
Posted: 01 Nov 2023, 09:02
I started using an online piano player, which lacked the ability to hold notes, distinguish between long and short notes, or adjust the tempo. This prompted me to create my first AutoHotkey (AHK) script, despite having no prior knowledge. I went from knowing absolutely nothing to completing the project, and I learned a lot along the way. I'd like to express my gratitude to @Rohwedder . While I didn't directly use any of his suggestions, his input gave me valuable inspiration. I acknowledge that my script may not be the best and can be further improved, but it serves my needs, and for that, I'm content. Thank you.
Also note length determiner:
"_" for 1/2 BPM
"-" for 1/4 BPM
"." for 1/16 BPM
and nothing for 1/8 BPM
Also note length determiner:
"_" for 1/2 BPM
"-" for 1/4 BPM
"." for 1/16 BPM
and nothing for 1/8 BPM
Code: Select all
#SingleInstance, Force
Gui, Font, c20C20E
Gui, Add, Text, x10 y10 w300, BPM
Gui, Add, Text, x10 y60, Key Stroke
Gui, Add, Text, x10 y240, F4 to Play
Gui, Add, Text, x10 y255, F8 to Pause
Gui, Font, Black
Gui, Add, Edit, x10 y25 w280 vBPM, 120
Gui, Add, Edit, x10 y75 w280 h150 vUserInput,
GuiControl, Focus, UserInput
Gui, Color, Black
Gui, +AlwaysOnTop
Gui, Show, w300 h280, OnlinePianoPlayer
return
F4::
!F4::
Gui, Submit, NoHide
UserInput := RegExReplace(UserInput, "(`n|`r|/)")
BPM := BPM ? BPM : 120
KeyArray := StrSplit(UserInput, A_Space, A_Space)
MKeyArray := ""
for each, Key in KeyArray ;Made by DelMii
{
KeyDelay := Floor(60000/BPM)
if InStr(Key,"_")
{
NKey := Trim(Key, "_")
NKeyDelay := Floor(KeyDelay*2)
MKeyArray := NKey
if (StrLen(Key) > 1)
{
NMKeyArray := StrSplit(MKeyArray)
for idx, MKey in NMKeyArray
{
SendInput {%MKey% down}
}
sleep NKeyDelay
for idx, MKey in NMKeyArray
{
SendInput {%MKey% up}
}
}
else
{
SendInput {%NKey% down}
Sleep NKeyDelay
SendInput {%NKey% up}
}
}
else if InStr(Key,"-")
{
NKey := Trim(Key, "-")
NKeyDelay := Floor(KeyDelay)
MKeyArray := NKey
if (StrLen(Key) > 1)
{
NMKeyArray := StrSplit(MKeyArray)
for idx, MKey in NMKeyArray
{
SendInput {%MKey% down}
}
sleep NKeyDelay
for idx, MKey in NMKeyArray
{
SendInput {%MKey% up}
}
}
else
{
SendInput {%NKey% down}
Sleep NKeyDelay
SendInput {%NKey% up}
}
}
else if InStr(Key,".")
{
NKey := Trim(Key, ".")
NKeyDelay := Floor(KeyDelay/4)
MKeyArray := NKey
if (StrLen(Key) > 1)
{
NMKeyArray := StrSplit(MKeyArray)
for idx, MKey in NMKeyArray
{
SendInput {%MKey% down}
}
sleep NKeyDelay
for idx, MKey in NMKeyArray
{
SendInput {%MKey% up}
}
}
else
{
SendInput {%NKey% down}
Sleep NKeyDelay
SendInput {%NKey% up}
}
}
else
{
NKey := Key
NKeyDelay := Floor(KeyDelay/2)
MKeyArray := NKey
if (StrLen(Key) > 1)
{
NMKeyArray := StrSplit(MKeyArray)
for idx, MKey in NMKeyArray
{
SendInput {%MKey% down}
}
sleep NKeyDelay
for idx, MKey in NMKeyArray
{
SendInput {%MKey% up}
}
}
else
{
SendInput {%NKey% down}
Sleep NKeyDelay
SendInput {%NKey% up}
}
}
}
return
F8::
Pause
return
GuiClose:
ExitApp