A Mixed Macro Autohotkey Application

This forum is a catch all for all posts that do not belong in other forums.

A Mixed Macro Autohotkey Application

Postby Technicality » Fri Feb 26, 2021 2:51 am

Hello there! Are you a new music player looking to blow away your friends with some crazy music skills? Or are you a long-time music player looking to up their game to the next level? Well, boy do I have the program for you. This Mixed Macro program does all the octave swapping for you! No more hassling with manual swapping! Chords like [2/4/6]/2/4/6/(2/4/6) can be played simply by pressing 246 246 246!

How do I use this program?
Well, it's incredibly simple. Just copy and paste music in either brackets and parenthesis format, or in music box arrows format into the UI box. Pressing F1 will load the song (which usually happens instantaneously) while pressing F2 starts the song (pressing F2 again will pause the song in case you want to swap to playing manual). F3 closes the application.

*Note* Maximum octave swapping speed is based on your guild wars 2 in game ping. If your ping is very low, you can open up the Ahk program in notepad, find "Delay = 80", and change 80 to a lower value (typically you'll want a delay higher than 50). Alternatively, if you ping is very high, you can increase the delay.
You'll want to mess around with different values for the delay to get a value that works best for your ping. Usually you'll end up with a Delay set somewhere between 25 - 200.

If the program skips an octave, you can manually swap back using 9 or 0 and continue playing.

Do I plan on continuing to improve this program? This depends on feedback, honestly. If you are interested in this program and would like to see it improved, then feel free to drop a comment here with any suggestions/ideas.
The UI will likely be the first place to see improvements, since it's quite abysmal.

Here's the link to the program:
http://www.mediafire.com/file/7em4u6pgdn9ctjz/Mixed_Macro.ahk/file
Last edited by Technicality on Fri Feb 26, 2021 6:06 pm, edited 4 times in total.
Technicality
 
Posts: 6
Joined: Thu Feb 25, 2021 11:04 pm

Re: A Mixed Macro Autohotkey Application

Postby Technicality » Fri Feb 26, 2021 2:55 am

On another note, I plan on working to develop a new/improved system for converting ABC notation into macros - with the emphasis being on creating a system with adjustable timings that prevent octaves from being skipped, and therefore fixing any broken macros that already exist. Since I've absolutely no experience with designing websites, this'll likely be in the form of another Autohotkey Application.
Technicality
 
Posts: 6
Joined: Thu Feb 25, 2021 11:04 pm

Re: A Mixed Macro Autohotkey Application

Postby Technicality » Mon Mar 01, 2021 1:48 am

Here's the code for the script if you'd rather just copy/paste it into your own script
*Note* this will only work if the encoding of the ahk file is UTF-8-BOM (encoding can be changed in notepad++)


#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#singleinstance force
ListLines Off
Process, Priority, , R
SetBatchLines, -1
SetKeyDelay, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1

Gui, Add, Text,, Paste Sheet Music Below
Gui, Add, Edit, R10 w400 vPianoCode
Gui, SongProgress:Add, Edit, w400 h300 vSheetProgress
Gui, Add, Text,, Copy/paste sheet music into the box, press F1 to load the song, F2 to start playing
Gui, Add, Text,, F3 will close the application
Gui, Add, Text, C , Version 0.2
StringCaseSense, On
Keys := []
noteOrSleep := []
nkey = 0
global notif := false
marked := false
nchord := ""


;~~~~~~~~~Try Out Different Delays~~~~~~~~~
Delay = 80
;~~~~~~~~~Try Out Different Delays~~~~~~~~~


rest = 0
count = 1
global isSleep := false
BlockedKeys := false
counter := new SecondCounter
recorder := new RecordCounter
Gui, Show
global Delay2 := Delay / 2
global Delay3 := 5
global Delay4 := Delay / 10


F1::
global isSleep, notif
Gui, Submit, Nohide
Loop, parse, PianoCode
{

var = %A_Loopfield%
prevKey := nkey
if((var = "1") || (var = "2") || (var = "3") || (var = "4") || (var = "5") || (var = "6") || (var = "7") || (var = "8") || (var = "▲") || (var = "▼") || (var = "[") || (var = "]") || (var = ")") || (var = "(") || (var = "")){
next := true
}
if (next){
if ((var = "▼") || (var = ")") || (var = "[")) {
nkey = 9
if (nChord > ""){
Keys.Push(nChord)
Keys.Push(nKey)
nChord := ""
Skip := true
}else{
Keys.Push(nKey)
Skip := true
nChord := ""
}
}
else if ((var = "▲") || (var = "(") || (var = "]")) {
nkey = 0
if (nChord > ""){
Keys.Push(nChord)
Keys.Push(nKey)
nChord := ""
Skip := true
}else{
Keys.Push(nKey)
Skip := true
marked := true
nChord := ""
}
}
else if (var = 1){
nkey = 1
}
else if (var = 2){
nkey = 2
}
else if (var = 3){
nkey = 3
}
else if (var = 4){
nkey = 4
}
else if (var = 5){
nkey = 5
}
else if (var = 6){
nkey = 6
}
else if (var = 7){
nkey = 7
}
else if (var = 8){
nkey = 8
}
else if (var = ""){
nkey =
notif := true
}
if(!Skip){
if(!marked){
if (notif = true){
if(nChord > ""){
Keys.Push(nChord)
}
notif := false
nChord := ""
}else{
nChord := nChord . nkey
}
}
}
Skip := false
}
next := false
marked := false
}
klen := Keys.Length()
nlen := NoteOrSleep.Length()
Gui, Font, s12, Verdana
;Gui, SongProgress:Show,,Sheet Music
Loop %klen%
{
toSheet := Keys[A_Index]
if StrLen(toSheet) > 1
{
toText .= "[" . Keys[A_Index] . "]" . " "
}else{
toText .= Keys[A_Index] . " "
}
}
;GuiControl,SongProgress:, SheetProgress, %toText%
return
F2::
klen := Keys.Length()
OctaveMode := !OctaveMode
BlockedKeys := !BlockedKeys
test := Keys[count]
if(test = 9){
SendInput {9 Up}
SendInput {9 Down}
count++
}
if(test = 0){
SendInput {0 Up}
SendInput {0 Down}
count++
}
return
$1::
charValue = 1
if(!BlockedKeys)
{
SendInput {1 down}
}
if (OctaveMode)
{
SendInput {1 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$1 Up::
SendInput {1 Up}
return
$2::
charValue = 2
if(!BlockedKeys)
{
SendInput {2 down}
}
if (OctaveMode)
{
SendInput {2 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$2 Up::
SendInput {2 Up}
return
$3::
charValue = 3
if(!BlockedKeys)
{
SendInput {3 down}
}
if (OctaveMode)
{
SendInput {3 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$3 Up::
SendInput {3 Up}
return
$4::
charValue = 4
if(!BlockedKeys)
{
SendInput {4 down}
}
if (OctaveMode)
{
SendInput {4 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$4 Up::
SendInput {4 Up}
return
$5::
charValue = 5
if(!BlockedKeys)
{
SendInput {5 down}
}
if (OctaveMode)
{
SendInput {5 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$5 Up::
SendInput {5 Up}
return
$6::
charValue = 6
if(!BlockedKeys)
{
SendInput {6 down}
}
if (OctaveMode)
{
SendInput {6 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif

}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$6 Up::
SendInput {6 Up}
return
$7::
charValue = 7
if(!BlockedKeys)
{
SendInput {7 down}
}
if (OctaveMode)
{
SendInput {7 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$7 Up::
SendInput {7 Up}
return
$8::
charValue = 8
if(!BlockedKeys)
{
SendInput {8 down}
}
if (OctaveMode)
{
SendInput {8 down}
pval := Keys[count]
pval := StrReplace(pval, charValue,,,1)
Keys[count] := pval
if(pval = ""){
v1 := Keys[count + 1]
v2 := Keys[count + 2]

if(v1 = 9){
SendInput {9 up}

count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if(v2 = 0){
count++
}else{
SendInput {9 Up}
SendInput {9 Down}
counter.Stop()
counter.Start()
if(v2 = 9){
count++
counter.Stop()
Sleep, Delay2
SendInput {9 Up}
Sleep, Delay2
SendInput {9 Down}
counter.Start()
}
}
}
if(v1 = 0){
SendInput {0 up}
count++
if (counter.count > 0){
dif := Delay - (counter.count * 10)
Sleep, dif
}
if (v2 = 9){
count++
}else{
SendInput {0 Up}
SendInput {0 Down}
counter.Stop()
counter.Start()
if(v2 = 0){
count++
counter.Stop()
Sleep, Delay2
SendInput {0 Up}
Sleep, Delay2
SendInput {0 Down}
counter.Start()
}
}
}
count++
}
}
return
$8 Up::
SendInput {8 Up}
return
$9::
SendInput {9 Down}
return
$9 Up::
SendInput {9 Up}
return
$0::
SendInput {0 Down}
return
$0 Up::
SendInput {0 Up}
return
class SecondCounter {
__New() {
this.interval := 1
this.count := 0
; Tick() has an implicit parameter "this" which is a reference to
; the object, so we need to create a function which encapsulates
; "this" and the method to call:
this.timer := ObjBindMethod(this, "Tick")
}

Start() {
; Known limitation: SetTimer requires a plain variable reference.
timer := this.timer
this.count := 0
SetTimer % timer, % this.interval
;ToolTip % "Counter started"
}
Stop() {
; To turn off the timer, we must pass the same object as before:
timer := this.timer
this.count := 0
SetTimer % timer, Off
;ToolTip % "Counter stopped at " this.count
}
; In this example, the timer calls this method:
Tick() {
global Delay2, Delay3
this.count++
if (this.count = Delay3){
SendInput {9 Up}
SendInput {0 Up}
}
if (this.count >= Delay4){
this.Stop()
this.count := 0
}
;ToolTip % this.count
}
}

F3::ExitApp
return
GuiClose:
ExitApp
Technicality
 
Posts: 6
Joined: Thu Feb 25, 2021 11:04 pm

Re: A Mixed Macro Autohotkey Application

Postby Technicality » Thu Mar 04, 2021 5:33 pm

I'd have to know what sheet music you were using. There are a number of issues that can occur if the sheet music you are using isn't correctly formatted. For starters, you'll want to test out something simple like [2/4/6] 2/4/6 (2/4/6)
Also, it isn't a macro player, in case you didn't know. Nothing happens after pressing F1 F2 until you actually start playing the music. You still need to press the correct number keys in order to play the song.
Technicality
 
Posts: 6
Joined: Thu Feb 25, 2021 11:04 pm



Return to General Discussion



Who is online

Users browsing this forum: No registered users and 6 guests


cron