Here's my macro:
I pasted the script into editor and here's what I get:
error "System Events got an error: Can’t get menu bar item "1" of menu bar 1 of process "Script Editor"." number -1728 from menu bar item "1" of menu bar 1 of process "Script Editor"
I'm pretty sure that the variable is simply not being declared as a string - not as a variable, but because I don't know a ton about Applescript, I'm not getting any solutions. I did check this page: https://wiki.keyboardmaestro.com/manual/Scripting
and this: https://wiki.keyboardmaestro.com/Scripting_the_Keyboard_Maestro_editor
and also a few posts. Maybe I just missed it though.
Well this is embarrassing. I just found a solution (not an optimal one I think) to the problem:
tell application "Keyboard Maestro Engine"
set tabApVar to getvariable "tabVar1"
end tell
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
end tell
tell application "System Events" to tell process activeApp
set tabApVar to tabApVar as integer
tell menu bar item tabApVar of menu bar 1
click
end tell
end tell
Hey @Jackson,
Another way to do it:
set tabVar to "1" as integer
tell application "System Events"
tell (first process whose frontmost is true)
tell menu bar item tabVar of menu bar 1
perform action "AXPress"
end tell
end tell
end tell
-Chris
@ccstone Thank you. The reason I don’t do it that way is because I want to use a KM variable. When I finish the macro, I’ll probably post it.
Hey @Jackson,
set tabVar to "1" as integer
Is just a stand-in for your getvariable Keyboard Maestro AppleScript.
The relevant bit is the System Events code block.
-Chris