I am trying to figure out a BETTER way of checking to see if the Clipboard History Switcher is already open/at-front. There is only 1 way that I know of to test this (explained below).
I have a macro setup for my mouse's middle-click that will pull up the history switcher OR if it is already open will paste the selected item (keystroke: enter).
My 'work-around': IF/THEN like so:
IF (any of the following are true) This screen: [Found Image Condition] contains
(at ~50% precision) in all screens execute the following actions
My 'middle-click' Macro:
If anyone knows of a different, better way of checking if the Clipboard History Switcher is activated please let me know. My work-around does work but is quite a hack, and can be slow (especially when system is under load). It seems like since the Clipboard History Switcher is built-in to KM there would be an easier way of determining this.
I have tried all of the "obvious" methods I could think of: "Is macro 'Activiate Clipboard History Switcher' active" & "Is front window title (or does it contain) 'Clipboard History Switcher' ..." etc. but none seem to work.
That runs very fast and seems to work great on my system. Are you trying to use native Keyboard Maestro actions? Also pretty nice, I haven't used an AppleScript for an If Action suprisinly or at least i don't recall ever doing so.
I love that they are left open personally and hope it stays that way.
P.S. Welcome back, nice to see you active again. I haven't seen you for the past couple weeks.
I think that'll break if the "Named Clipboard Switcher" is open but minimised. This script should cater for that eventuality as well:
tell application "System Events"
tell application process "Keyboard Maestro Engine"
try
set value of attribute "AXMinimized" of item 1 of (every window whose name is "Clipboard History Switcher") to false
return 1
on error
try
set value of attribute "AXMinimized" of item 1 of (every window whose name is "Named Clipboard Switcher") to false
on error
-- do nothing
end try
return 0
end try
end tell
end tell
You could do away with the error blocks and use your "get list, if list count > 0" construct if you prefer that more explicit way of doing things.
For me, if I open the "Named Clipboard Switcher" then minimise it the macro needs to be run twice to get "Clipboard History Switcher" to appear.
First run there will be no windows with the name "Clipboard History Switcher" so the script returns 0 and the "Activate..." action executed -- that changes the minimised "Named Clipboard Switcher" to the minimised "Clipboard History Switcher". Second run will unminimise that window.
tell application id "com.apple.systemevents" to tell application process "Keyboard Maestro Engine"
if window "Clipboard History Switcher" exists then
tell application "Keyboard Maestro Engine" to activate
set value of (attribute "AXMinimized" of window "Clipboard History Switcher") to false
else
error
end if
end tell