When a macro is open in the Keyboard Maestro editor, this macro can be used to scroll to the top or bottom of the macro. When the macro scrolls to the bottom, the last macro action is selected. When the macro scrolls to the top, the first macro action is selected or alternatively the macro icon image well is selected.
Hot Keys
Hot Key
Behavior
⌥⌘↓
Scroll to the bottom and select the last action
⌥⌘↑
Scroll to the top and select the first action
⌃⌥⌘↑
Scroll to the top and select the macro icon image well
TESTED WITH
• Keyboard Maestro 11.0.3
• Sequoia 15.1 (24B5055e)/MacBookPro18,2
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
( expand / collapse )
1.0 - initial version
2.0
a) For scrolling to the top (with or without selecting the macro icon image well), simplified the logic using information shared by @NaOH.
b) Since the scrolling to the top logic was changed, the PREREQUISITES are only required when scrolling to the bottom.
b) The above change eliminates two earlier requirements: 1) The System Setting (or System Preference) Show scroll bars had to be set to Always, and 2) The entire Keyboard Maestro editor had to be visible on the mac display.
The above change eliminates two earlier requirements: 1) The System Setting (or System Preference) Show scroll bars had to be set to Always, and 2) The entire Keyboard Maestro editor had to be visible on the mac display.
Since posting Version 3.0 I have noticed that the scroll down AppleScript (largely supplied by @Nige_S) occasionally fails. The symptom will be that the last action gets selected but the editor does not scroll to the very bottom. I've not been able to determine a method to reproduce the error. But here's the error from Engine.log:
2024-10-01 13:42:00 Action 16249560 failed: Execute an AppleScript failed with script error: text-script:592:597: execution error: System Events got an error: Can’t get group 6 of window 1 of process "Keyboard Maestro". Invalid index. (-1719)
Also, I've not been able to find steps to recover proper operation. I've tried stopping and restarting the Keyboard Maestro editor (and Engine), and that hasn't necessarily worked. I do know, however, that the AppleScript will sometimes resume normally operation before I log out and back in.
Here's the AppleScript (the bad parts are mine; the good stuff is from @Nige_S):
try
tell application "Keyboard Maestro"
set selectedMacroList to selected macros
if length of selectedMacroList = 1 then
set currentMacro to item 1 of selectedMacroList
select the last action of the currentMacro
end if
end tell
tell application "System Events"
tell process "Keyboard Maestro"
if name of window 1 is "New Action" then
set winIndex to 2
else
set winIndex to 1
end if
tell window winIndex
tell group 6
tell splitter group 1
tell scroll area 3
tell scroll bar 1
-- moves thumb to top(0)/bottom(1)
set value to 1
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end try
Not a solution to your AS problem but this (cobbled from several examples on this topic) has been working for me with/without scroll bars on both old Intel and new Apple Silicon. It's also under 6K.
In addition to top and bottom and third option (left arrow) goes to the middle:
That's the same error we were getting when the "New Action" pane was open (before the if block was added), suggesting that your Editor window isn't window 1. To troubleshoot, try wrapping tell group 6 and below in an try block, displaying the window 1 name on error:
...
try
tell group 6
tell splitter group 1
...
end tell
end tell
on error
display dialog (name of window 1)
end try