OnlinePianoPlayer for roblox and more

Post gaming related scripts
Delmii
Posts: 3
Joined: 31 Oct 2023, 09:00

OnlinePianoPlayer for roblox and more

Post by Delmii » 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

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

BeenNg
Posts: 1
Joined: 02 Nov 2023, 00:30

Re: OnlinePianoPlayer for roblox and more

Post by BeenNg » 02 Nov 2023, 00:33

Hi can you make it more userfriendly like i want to use different symbol to designate note length and like have shift key for black note on roblox? thank you

Delmii
Posts: 3
Joined: 31 Oct 2023, 09:00

Re: OnlinePianoPlayer for roblox and more

Post by Delmii » 03 Nov 2023, 07:27

sorry i forgot the most important thing but here we go this should be the final and last thing to this script cuz im too lazy to edit more, the 1/4 is none suffix as default

Code: Select all

#SingleInstance, Force
Gui, Font, c20C20E

Gui, Add, Text, x10 y10 w300, BPM
Gui, Add, Text, x30 y50, Whole
Gui, Add, Text, x100 y50, 1/2th
Gui, Add, Text, x170 y50, 1/8th
Gui, Add, Text, x240 y50, 1/16th
Gui, Add, Text, x10 y100, Key Stroke
Gui, Add, Text, x10 y280, F4 to Play
Gui, Add, Text, x10 y295, F8 to Pause

Gui, Font, Black
Gui, Add, Edit, x10 y25 w280 vBPM, 120
Gui, Add, Edit, x10 y120 w280 h150 vUserInput,
Gui, Add, Edit, x14 y67 w60 vOneOne, _
Gui, Add, Edit, x84 y67 w60 vOneTwo, -
Gui, Add, Edit, x154 y67 w60 vOneEight, '
Gui, Add, Edit, x224 y67 w60 vOneSixteenth, .
GuiControl, Focus, UserInput

Gui, Color, Black
Gui, +AlwaysOnTop
Gui, Show, w300 h320, 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, OneOne)
        {
            NKey := Trim(Key, OneOne)
            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
                {
					if (RegExMatch(NKey,[A-Z]))
						{
							SendInput {A_Space down}
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
							SendInput {A_Space up}
						}
					else
						{
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
						}
                }
        }
    else if InStr(Key, OneTwo)
        {
            NKey := Trim(Key, OneTwo)
            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
                {
					if (RegExMatch(NKey,[A-Z]))
						{
							SendInput {A_Space down}
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
							SendInput {A_Space up}
						}
					else
						{
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
						}
                }
        }
    else if InStr(Key, OneEight)
        {
            NKey := Trim(Key, OneEight)
            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
                {
					if (RegExMatch(NKey,[A-Z]))
						{
							SendInput {A_Space down}
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
							SendInput {A_Space up}
						}
					else
						{
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
						}
                }
        }
    else if InStr(Key, OneSixteenth)
        {
            NKey := Trim(Key, OneSixteenth)
            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
                {
					if (RegExMatch(NKey,[A-Z]))
						{
							SendInput {A_Space down}
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
							SendInput {A_Space up}
						}
					else
						{
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
						}
                }
        }
    else
        {
            NKey := 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
                {
					if (RegExMatch(NKey,[A-Z]))
						{
							SendInput {A_Space down}
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
							SendInput {A_Space up}
						}
					else
						{
							SendInput {%NKey% down}
							Sleep NKeyDelay
							SendInput {%NKey% up}
						}
                }
        }
}
return


F8::
Pause
return

GuiClose:
ExitApp


emmangoatedd
Posts: 1
Joined: 13 Jan 2024, 14:17

Re: OnlinePianoPlayer for roblox and more

Post by emmangoatedd » 13 Jan 2024, 14:25

Greetings! I was hoping to inquire if I may obtain your gracious consent to utilize this particular piece of content, either by means of a GitHub link or Mediafire, for the purpose of demonstrating to others how to obtain it. Your kind authorization would be greatly appreciated. Thank you!

Post Reply

Return to “Gaming Scripts (v1)”