#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance force ; Replaces script (Reloads). #Persistent ; to make it run indefinitely #IfWinActive ahk_exe S:\MuseScore 3.6 portable\MuseScorePortable\App\MuseScore\bin\MuseScore3.exe ; Enables Hotkeys when MuseScore3 Window is Active #Include Coordinates_stripped.ahk ; All coordinates are managed in this external file ; The Include directive causes the script to behave as though ; the specified file's contents are present at this exact position ; Replace the path S:\etc. with your location of MuseScore3.exe ; ♣================================================================================================ ~[ & F1:: CoordMode, Tooltip, Screen Tooltip, F1 Search and Select, ToolT_F1_X, 0, 1 ; tooltip (1) Search and Select Return ~] & F1:: MsgBox, 4132, Color Search and Select, Are you sure you want to exit? IfMsgBox, Yes ExitApp Return ~[ & 1:: ; general info group #1 + rightclick selection commands (contextual menu) MsgBox, 4096, F1: Search and Select - stripped version [ + 1, ( Select all ELEMENTS except notes and rests For Press plus All similar Same subtype Range Control RightButton # MidButton Score Left Shift RightButton MidButton System √ Right Shift RightButton MidButton Staff CapsLock RightButton MidButton Voice Alt RightButton * MidButton * Staff+Voice Win RightButton MidButton Action - score, voice, system or staff: click an element. Action - range: don't click the element but position the mouse on it # Click an element + hotkey opens the Window Select * Also for voice in range. Action as in range √ In Page View. In Continuous View it operates on score. Elements include Beams, Flags, Dots and Stems -------------------------------------------------------------------------------------------- Select all NOTES of the same In Range/Score In Staff Duration ] + D [ + D Pitch ] + P [ + P Notename ] + N [ + N Voice ] + V [ + V Action-range/score: Action-staff: Select range or all and Click a note of Position mouse on note the right type (or rest for duration) Select only all noteheads or only all rests in range ] + H Notes include Noteheads, Grace Notes and Rests Select all noteheads in range M + H Select all grace notes in range M + G Select all rest in range M + R Info Mouse to Color - Voices [ + C ) Return ~[ & c:: ; colorselect MsgBox, 4096, F1: Search and Select - stripped version [ + C, ( INSTANT SELECTION Mouse moves to selected element in voice and clicks it Voice 1 Alt + Z Voice 2 Alt + X Voice 3 Alt + C Voice 4 Alt + D Voice 1234 Alt + S ) Return ; ♣================================== SEARCH VOICE COLORS ========================================= ~!s:: ; Search color all voices and click found element CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV1, , Fast RGB ; voice 1 if ErrorLevel PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV2, , Fast RGB ; voice 2 if ErrorLevel PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV3, , Fast RGB ; voice 3 if ErrorLevel PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV4, , Fast RGB ; voice 4 if ErrorLevel MsgBox, 4144, Search for voice 1234 element, Color not found. Maybe there is no element selected.`nMaybe the selected element is set invisible.`nWith small elements you could try a higher zoom factor. Click, %ElementX%, %ElementY% Return ~!z:: ; Search color voice 1 and click found element CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV1, , Fast RGB if ErrorLevel { MsgBox, 4144, Search for voice 1 element, Color not found. Maybe there is no element selected.`nMaybe the selected element is set invisible.`nWith small elements you could try a higher zoom factor. Return } MouseMove, ElementX, ElementY + 4 ; 4 pixels lower to prevent hitting third in another voice Click Return ~!x:: ; Search color voice 2 and click found element CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV2, , Fast RGB if ErrorLevel MsgBox, 4144, Search for voice 2 element, Color not found. Maybe there is no element selected.`nMaybe the selected element is set invisible.`nWith small elements you could try a higher zoom factor. else { MouseMove, ElementX, ElementY + 4 ; 4 pixels lower to prevent hitting third in another voice Click Return } Return ~!c:: ; Search color voice 3 and click found element CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV3, , Fast RGB if ErrorLevel MsgBox, 4144, Search for voice 3 element, Color not found. Maybe there is no element selected.`nMaybe the selected element is set invisible.`nWith small elements you could try a higher zoom factor. else { MouseMove, ElementX, ElementY + 4 ; 4 pixels lower to prevent hitting third in another voice Click Return } Return ~!d:: ; Search color voice 4 and click found element CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, ElementX, ElementY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, ColorV4, , Fast RGB if ErrorLevel MsgBox, 4144, Search for voice 4 element, Color not found. Maybe there is no element selected.`nMaybe the selected element is set invisible.`nWith small elements you could try a higher zoom factor. else { MouseMove, ElementX, ElementY + 4 ; 4 pixels lower to prevent hitting third in another voice Click Return } Return ; ♣========================== COLORED RANGE ===== SELECTION PAIR 1 ================================ ~y & f1:: ; set left color (1) magenta 0xff00ff ~l & [:: ; set left color (1) magenta 0xff00ff CoordMode, Mouse, Screen MouseGetPos, StartX, StartY ImageSearch, , , IM_01_X1, IM_01_Y1, IM_01_X2, IM_01_Y2, *40 IM_01_Inspector_Inspector.png If ErrorLevel ; if 'Inspector' is not in the correct spot { MsgBox, 4112, Inspector Check, The screen is not in the defined state.`nThe macro will exit. Return } Click, %IN_012X%, %IN_012Y% ; I(0012) color picker rectangular (black) - OVERLAP all elements Sleep, 200 CoordMode, Mouse, Window Click, %RGB_X%, %RGB_Y% ; Window Select Color HTML: #RGB rectangular Sleep, 100 Send ^a Sleep, 50 Send {del} Sleep, 50 Send {Raw}#ff00ff ; select left color (1) magenta Sleep, 50 Send {Enter} CoordMode, Mouse, Screen MouseMove, StartX, StartY Return ~y & f2:: ; set right color (1) lime 0x00ff00 ~l & ]:: ; set right color (1) lime 0x00ff00 CoordMode, Mouse, Screen MouseGetPos, StartX, StartY ImageSearch, , , IM_01_X1, IM_01_Y1, IM_01_X2, IM_01_Y2, *40 IM_01_Inspector_Inspector.png If ErrorLevel { MsgBox, 4112, Inspector Check, The screen is not in the defined state.`nThe macro will exit. Return } Click, %IN_012X%, %IN_012Y% ; I(0012) color picker rectangular (black) - OVERLAP all elements Sleep, 200 CoordMode, Mouse, Window Click, %RGB_X%, %RGB_Y% ; Window Select Color HTML: #RGB rectangular Sleep, 100 Send ^a Sleep, 50 Send {del} Sleep, 50 Send {Raw}#00ff00 ; select right color (1) lime Sleep, 50 Send {Enter} CoordMode, Mouse, Screen MouseMove, StartX, StartY Return ~y & 1:: ; go to left color (1) magenta 0xff00ff ~l & LButton:: ; go to left color (1) magenta 0xff00ff Send {Escape} Sleep, 100 CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, MagentaX, MagentaY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0xff00ff, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of left element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { MouseMove, MagentaX, MagentaY+=2 Click Return } Return ~y & 2:: ; go to right color (1) lime 0x00ff00 ~l & RButton:: ; go to right color (1) lime 0x00ff00 Send {Escape} Sleep, 100 CoordMode, Mouse, Screen CoordMode, Pixel, Screen PixelSearch, LimeX, LimeY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0x00ff00, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of right element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { MouseMove, LimeX, LimeY+=2 Click Return } Return ~y & f9:: ; select colored range (1) from magenta to lime ~l & MButton:: ; select colored range (1) from magenta to lime ~l & =:: ; select colored range (1) from magenta to lime CoordMode, Mouse, Screen Send {Escape} Sleep, 100 PixelSearch, MagentaX, MagentaY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0xff00ff, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of left element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { Send {Click %MagentaX%, %MagentaY%} Sleep, 50 PixelSearch, LimeX, LimeY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0x00ff00, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of right element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { Send +{Click %LimeX%, %LimeY%} Sleep, 100 Return } } Return ~l & -:: ; reset colored range (1) from magenta to lime CoordMode, Mouse, Screen Send {Escape} Sleep, 100 PixelSearch, MagentaX, MagentaY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0xff00ff, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of left element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { Send {Click %MagentaX%, %MagentaY%} Sleep, 50 PixelSearch, LimeX, LimeY, % CSA_X1, % CSA_Y1, % CSA_X2, % CSA_Y2, 0x00ff00, , Fast RGB if ErrorLevel { MsgBox, 4112, In search of right element [Pair 1], The color was not found.`nMaybe the element is off screen.`nOr try a higher zoom factor. Return } else { Send +{Click %LimeX%, %LimeY%} Sleep, 100 Click, %IN_002X%, %IN_002Y% ; I(002) rectangular Set Color = Reset Color - ELEMENT GROUP Sleep, 50 Click, %MagentaX%, %MagentaY% Return } } Return ; ♣========================= SELECT ELEMENTS == in contextual menu 6 x down ======================= ~^RButton:: ; Range > all similar Select_CM := "ras" ; CM for contextual menu Goto, ContextMenu ~<+RButton:: ; Score > all similar (Left Shift) Select_CM := "scas" Goto, ContextMenu ~>+RButton:: ; Same system > all similar (Right Shift) Select_CM := "sysas" Goto, ContextMenu ~!RButton:: ; Range > similar > same voice Select_CM := "rassv" Goto, ContextMenu ~CapsLock & RButton:: ; Staff > all similar Select_CM := "stas" Goto, ContextMenu #RButton:: ; Staff > all similar > same voice Select_CM := "stassv" Goto, ContextMenu ~^MButton:: ; Range > same subtype Select_CM := "rsst" Goto, ContextMenu ~<+MButton:: ; Score > same subtype (Left Shift) Select_CM := "scsst" Goto, ContextMenu ~>+MButton:: ; Same system > same subtype (Right Shift) Select_CM := "ssyssst" Goto, ContextMenu ~!MButton:: ; Range > same subtype > same voice Select_CM := "rsstsv" Goto, ContextMenu ~CapsLock & MButton:: ; Staff > same subtype Select_CM := "stsst" Goto, ContextMenu #MButton:: ; Staff > same subtype > same voice Select_CM := "stsstsv" Goto, ContextMenu ContextMenu: CoordMode, Mouse, Screen Gosub, InspectorCheck ; see subroutine at end of script ImageSearch, , , IM_03_X1, IM_03_Y1, IM_03_X2, IM_03_Y2, *40 IM_03_Inspector_Nothing_Selected.png If (Errorlevel = 0) { MsgBox, 4112, Selection Status, Nothing selected!`nThe macro will exit. Return } MouseGetPos, StartX, StartY ; original mouse position is stored Click, right ; executing each line takes about 30 ms If Select_CM in ras Sleep, 150 If Select_CM in scas,stas,stassv,rsst,scsst,stsst,stsstsv Sleep, 50 If Select_CM in sysas,rassv,ssyssst,rsstsv Sleep, 600 Loop, 6 { Send {down} Sleep, 50 } Sleep, 100 ; important! Send {right} If Select_CM in ras { Sleep, 350 Send {down} Sleep, 100 Send {down} Sleep, 100 } If Select_CM in scas Sleep, 100 If Select_CM in sysas,rassv,stassv,rsstsv,stsst,stsstsv { Sleep, 50 Send {up} Sleep, 50 } If Select_CM in stas { Sleep, 50 Send {down} Sleep, 50 } If Select_CM in rsst,scsst,ssyssst { Sleep, 200 Send {up} Sleep, 50 } ; protection against rightclick on note or rest If Select_CM in ras ImageSearch, , , StartX, StartY - RC_CM_Y1, StartX + RC_CM_X2, StartY + RC_CM_Y2, Remove_Selected_Range_Blue.png If Select_CM in scas ImageSearch, , , StartX, StartY - RC_CM_Y1, StartX + RC_CM_X2, StartY + RC_CM_Y2, Swap_with_Clipboard_Blue.png If Select_CM in sysas,rassv,stassv,rsst,scsst,ssyssst,rsstsv,stsst,stsstsv ImageSearch, , , StartX, StartY - RC_CM_Y1, StartX + RC_CM_X2, StartY + RC_CM_Y2, Paste_Blue.png If Select_CM in stas ImageSearch, , , StartX, StartY - RC_CM_Y1, StartX + RC_CM_X2, StartY + RC_CM_Y2, Delete_Blue.png If (ErrorLevel = 0) { ToolTip, Element Check. This hotkey is`nNOT for notes or rests!`nPress Z., StartX, StartY - 50, 2 ; (*change*?) KeyWait, z, d ToolTip, , , , 2 ; close tooltip (2) Send {escape} Return } If Select_CM in sysas,rassv,stassv,rsst,scsst,ssyssst,rsstsv,stsst,stsstsv { Send {Enter} ; opens Window Select Sleep, 200 CoordMode, Mouse, Window If Select_CM in sysas,ssyssst Click, %WS_05_X%, %WS_05_Y% ; (WS_05) Window Select Same system If Select_CM in stassv,stsst,stsstsv { Click, %WS_02_X%, %WS_02_Y% ; (WS_02) Window Select Same staff Sleep, 50 } If Select_CM in ssyssst Sleep, 50 If Select_CM in rsst,scsst,ssyssst,rsstsv,stsst,stsstsv Click, %WS_01_X%, %WS_01_Y% ; (WS_01) Window Select Same subtype If Select_CM in rsstsv,stsstsv,rsst Sleep, 50 If Select_CM in rassv,stassv,rsstsv,stsstsv Click, %WS_04_X%, %WS_04_Y% ; (WS_04) Window Select Same voice If Select_CM in rassv,stassv,rsstsv Sleep, 50 If Select_CM in rassv,stassv,rsst,rsstsv Click, %WS_03_X%, %WS_03_Y% ; (WS_03) Window Select In selection Sleep, 50 Send {Enter} ; OK } If Select_CM in ras,scas,stas Send {Enter} ; OK CoordMode, Mouse, Screen MouseMove, StartX, StartY ; back to original position Return ; ♣===================== SELECT NOTES ======== in contextual menu 4 x up ========================== ; 4 x up - Closing bracket: Range - Opening bracket: Staff ~] & d:: ; Range > all notes with the same duration Select_NR_CM := "rd" Goto, ContextMenu_NR ~] & p:: ; Range > all notes with the same pitch Select_NR_CM := "rp" Goto, ContextMenu_NR ~] & n:: ; Range > all notes with the same note name Select_NR_CM := "rn" Goto, ContextMenu_NR ~] & v:: ; Range > all notes of the same voice Select_NR_CM := "rv" Goto, ContextMenu_NR ~] & h:: ; Range > only the noteheads or only the rests Select_NR_CM := "nhr" Goto, ContextMenu_NR ~[ & d:: ; Staff > all notes with the same duration Select_NR_CM := "sd" Goto, ContextMenu_NR ~[ & p:: ; Staff > all notes with the same pitch Select_NR_CM := "sp" Goto, ContextMenu_NR ~[ & n:: ; Staff > all notes with the same note name Select_NR_CM := "sn" Goto, ContextMenu_NR ~[ & v:: ; Staff > all notes of the same voice Select_NR_CM := "sv" Goto, ContextMenu_NR ContextMenu_NR: CoordMode, Mouse, Screen MouseGetPos, StartX, StartY ; original mouse position is stored Click, right Sleep, 50 Send {up} ; executing each line adds 30 ms of sleep Sleep, 50 Send {up} ; this delay is needed when many notes are selected Sleep, 50 Send {up} ; executing each line takes about 30 ms Sleep, 50 Send {up} Sleep, 50 Send {right} Sleep, 50 If Select_NR_CM in nhr { Send {down 2} Goto, FinishSelect_NR_CM } Send {up} Sleep, 50 Send {Enter} ; opens Window Select Notes Sleep, 200 ; increase sleeptime if needed CoordMode, Mouse, Window If Select_NR_CM in rd,sd Click, %WSN_05X%, %WSN_05Y% ; (WSN_05) Window Select Notes Same duration If Select_NR_CM in rp,sp Click, %WSN_02X%, %WSN_02Y% ; (WSN_02) Window Select Notes Same pitch If Select_NR_CM in rn,sn Click, %WSN_06X%, %WSN_06Y% ; (WSN_06) Window Select Notes Same note name If Select_NR_CM in rv,sv Click, %WSN_09X%, %WSN_09Y% ; (WSN_09) Window Select Notes Same voice Sleep, 50 If Select_NR_CM in rd,rp,rn,rv Click, %WSN_08X%, %WSN_08Y% ; (WSN_08) Window Select Notes In selection If Select_NR_CM in sd,sp,sn,sv Click, %WSN_07X%, %WSN_07Y% ; (WSN_07) Window Select Notes Same staff FinishSelect_NR_CM: Sleep, 50 Send {Enter} ; OK CoordMode, Mouse, Screen MouseMove, StartX, StartY ; back to original position Return ~m & h:: ; range: select all note heads Selection := "Noteheads" Goto, RangeSelCommand ~m & g:: ; range: select all grace notes Selection := "GraceNotes" Goto, RangeSelCommand ~m & r:: ; range: select all rests Selection := "Rests" Goto, RangeSelCommand RangeSelCommand: ImageSearch, , , IM_01_X1, IM_01_Y1, IM_01_X2, IM_01_Y2, *40 IM_01_Inspector_Inspector.png If ErrorLevel { MsgBox, 4112, Inspector Check, The screen is not in the defined state.`nThe macro will exit. Return } ImageSearch, , , SB_X1, SB_Y1, SB_X2, SB_Y2, *40 Statusbar_Range_Selection.png If ErrorLevel { MsgBox, 4144, Select notes or rests, No range selected!`nSelect a range and try again. Return } MouseGetPos, StartX, StartY If (Selection = "Noteheads") Click, %IN_007_X%, %IN_007_Y% ; I(007) Select Notes - ELEMENT GROUP If (Selection = "GraceNotes") Click, %IN_008_X%, %IN_008_Y% ; I(008) Select Grace Notes - ELEMENT GROUP If (Selection = "Rests") Click, %IN_009_X%, %IN_009_Y% ; I(009) Select Rests - ELEMENT GROUP Sleep, 50 MouseMove, StartX, StartY Return ; ♣===================================== SUBROUTINES ============================================== InspectorCheck: ImageSearch, , , IM_01_X1, IM_01_Y1, IM_01_X2, IM_01_Y2, *40 IM_01_Inspector_Inspector.png If ErrorLevel { Send {Click} Sleep, 100 Send {Escape} ; to suppress the contextual menu Sleep, 50 MsgBox, 4112, Inspector Check, The screen is not in the defined state.`nThe macro will exit., 1 Exit } Return PickColor: Click, %IN_012_X%, %IN_012_Y% ; I(012) color picker rectangular (black) - OVERLAP all elements Sleep, 200 CoordMode, Mouse, Window Click, %RGB_X%, %RGB_Y% ; Window Select Color HTML: #RGB rectangular Sleep, 100 Send ^a Sleep, 50 Return