Hello!
Does anyone know a way to close KM "Display Text" window with a KM action?
Hello!
Does anyone know a way to close KM "Display Text" window with a KM action?
Hey Kirill,
You have to use AppleScript and System Events and talk to the window/windows in the Keyboard Maestro Engine.
If your system in non-English the "role description" might be localized into something else.
tell application "System Events"
tell application process "Keyboard Maestro Engine"
tell front window
tell (first button whose role description is "close button")
perform action "AXPress"
end tell
end tell
end tell
end tell
You can use the same basic technique to move and resize these windows as well.
-Chris
Hey Kirill,
Not sure – it works fine on my macOS 10.12.6 Sierra system.
Try running this:
tell application "System Events"
tell application process "Keyboard Maestro Engine"
tell front window
properties of every button
end tell
end tell
end tell
-Chris
Looks like i got it, AS detects a palette as a front KM window and tries to close it, using you script i found the name of the "OK" button in the "Display text" window. So, i have to locate a correct KM window which may be not frontmost.
Please advise.
Whups – I forgot about palettes...
Try this:
tell application "System Events"
tell application process "Keyboard Maestro Engine"
tell (first window whose name is "Keyboard Maestro - Display Text")
tell (first button whose role description is "close button")
perform action "AXPress"
end tell
end tell
end tell
end tell
-Chris
Simulate Keystroke "Return" Action.
Works perfectly, as all your other solutions !
Is there a way to close all of them at once instead of one at a time?
Option clicking the close button will close all of the Display Text in Window windows.
great! thank you. today i ran the above applescript on repeat about 2000 times. not joking.
Any way to assign it to a shortcut? I tried this, but the modifier hold bit doesn't work and it only closes one of the windows:
activate application "Keyboard Maestro Engine"
tell application "System Events"
tell process "Keyboard Maestro Engine"
option key down
click button 2 of window "Keyboard Maestro - Display Text"
option key up
end tell
end tell
Ideally, I'd like to assign it to the Escape key, so the logic would be as follows:
If a window exists whose title includes "Display Text", then ⌥-click it's close button.
Else, simulate the Escape key.
There is no keyboard shortcut.
You can do this:
Some notes:
Perfect. Thanks!
Nice work! Yeah that's exactly what I was after.
FWIW, @peternlewis' version is snappier, as is often the case with KM vs AS, not that it really matters for something like this.
Yep, AS will usually be slower than most other options
But my inexperience with KM means I don't know what other windows the Engine might have open, so I went the cautious route and only closed those with "Display Text" in the title bar (as you asked). Really should have gone tighter and used "ends with" rather than "contains", to be even more sure.