The URL method does the same thing as the AppleScript method:
tell application "Keyboard Maestro"
editMacro "Name or UUID"
end tell
This opens the group for editing, and I was trying to avoid that.
However – that got me thinking – and I can use it to speed up my macro a bit.
tell application "Keyboard Maestro"
editMacro "All Macros"
end tell
tell application "System Events"
tell application process "Keyboard Maestro"
tell (first window whose subrole is "AXStandardWindow")
tell scroll area 2 of splitter group 1 of group 1
set focused to true
end tell
end tell
end tell
end tell
“All Macros” may not exist - I thought I’d mention that. I accidentally renamed my All Macros group yesterday. It wasn’t at the top of the list either. Just thought I’d point that out, in case you didn’t think of it.
Well – I think Peter should make “All Macros” completely immutable – so there’s a check-point the user can’t screw up.
He’s made “all:” immutable as long as the group is named “All Macros” but allowed the user to change the name. If the user changes the name then “all:” loses its immutability.
Few users are going to goof this up, so I decided not to worry about it.
However I don’t know how it localizes – so there’s something to think about.
You would have had to have done more than that, because those two steps will simply move you to another group in the groups panel.
This is why I wasn’t content with edit macros "All Macros", because that leaves the focus in the group name field.
My macro moves focus away from the group name field making it more difficult for the user to screw things up.
If you simply must have some error-checking in there:
--------------------------------------------------------------------------------
try
tell application "System Events"
tell application process "Keyboard Maestro"
tell (first window whose subrole is "AXStandardWindow")
tell group 1 of scroll area 1 of splitter group 1 of group 1
if accessibility description ≠ "All Macros" then
error "Your “All Macros” group appears to be missing!"
end if
end tell
selectAllMacrosGroup() of me
tell scroll area 2 of splitter group 1 of group 1 to set focused to true
end tell
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
--------------------------------------------------------------------------------
on selectAllMacrosGroup()
tell application "Keyboard Maestro"
editMacro "All Macros"
end tell
end selectAllMacrosGroup
--------------------------------------------------------------------------------
Open the Keyboard Maestro Editor Macro Edit History menu for viewing or type-selecting an item.
-Chris
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/08/11 22:43
# dMod: 2016/08/11 22:53
# Appl: System Events & Keyboard Maestro Editor
# Task: Access the Macro Edit History Menu of the Keyboard Maestro Editor.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Editor, @History
--------------------------------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell button 1 of group 5
perform action "AXShowMenu" -- Open the History Button Menu.
end tell
end tell
end tell
key code 125 -- Select the first menu item.
end tell
--------------------------------------------------------------------------------
SHARE THE SELECTED ITEMS IN THE KEYBOARD MAESTRO EDITOR TO THE FORUM
Hey Folks,
I finally got tired of doing this manually. The macro takes you to the point of sharing {Both} to the forum – just as if you manually clicked through the process.
-Chris
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/08/11 22:43
# dMod: 2016/08/11 23:19
# Appl: System Events & Keyboard Maestro Editor
# Task: Share the Selected Items in the Keyboard Maestro Editor to the Forum.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Editor, @Send, @Forum
--------------------------------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro"
set frontmost to true
tell window "Keyboard Maestro Editor"
tell group 2
tell button 1
perform action "AXShowMenu" -- Open the Share Button Menu.
end tell
end tell
end tell
end tell
keystroke "k"
key code 36
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell button "Both" of sheet 1
perform action "AXPress"
end tell
end tell
end tell
end tell
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/08/11 22:43
# dMod: 2016/08/11 23:51
# Appl: System Events & Keyboard Maestro Editor
# Task: Select the Next Edited Macro.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Editor, @Select, @Previously, @Run, @Macro
--------------------------------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro"
set frontmost to true
tell window "Keyboard Maestro Editor"
tell group 4
tell button 2
if enabled = true then
perform action "AXPress" -- Select the Next Edited Macro
else
beep
end if
end tell
end tell
end tell
end tell
end tell
--------------------------------------------------------------------------------
Toggle the enabled/disabled state of the selected macro(s) – no matter what is selected in the Keyboard Maestro editor.
Run from an Execute an AppleScript action.
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/12/20 08:00
# dMod: 2016/12/20 08:08
# Appl: System Events & Keyboard Maestro Editor
# Task: Toggle the Enabled-Disabled state of the selected macros.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Toggle, @Enabled, @Disabled, @State, @Selected, @Macros
# Note: Likely to fail on non-English language systems due to localization issues.
--------------------------------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro"
tell (first window whose subrole is "AXStandardWindow")
tell (first button whose accessibility description is "Enable or Disable Macro")
perform action "AXPress"
end tell
end tell
end tell
end tell
--------------------------------------------------------------------------------
Here’s how to automate the [Rename] contextual-menu item for the selected action.
If more than one action is selected then the contextual-menu pops open to allow you to type-select.
Run it from an Execute an AppleScript action.
-Chris
------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/05/22 14:45
# dMod: 2017/05/22 14:53
# Appl: Keyboard Maestro Editor
# Task: Select Rename in the contextual menu of the selected action.
# : If more than 1 action is selected bring up the contextual menu.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Keyboard_Maestro, @System_Events, @Select, @Rename, @Contextual_Menu, @Menu, @Selected, @Action
------------------------------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell group 1
tell splitter group 1
tell scroll area 3
set selectedGroups to groups whose selected is true
if selectedGroups ≠ {} then
set theAction to item 1 of selectedGroups
tell theAction
perform action "AXShowMenu"
tell menu 1
tell menu item "Rename…"
perform action "AXPress"
end tell
end tell
end tell
end if
end tell
end tell
end tell
end tell
end tell
end tell
------------------------------------------------------------------------------