I'm trying to create a macro to change f.lux but I can't use "image search" because the f.lux menu is semitransparent, so anytime the background window changes, the macro doesn't work. Any idea how to press the "Preferences..." item programmatically?
I use the app âBartender 2â. Here is a short video. At Intresse, I can give you the macro.
Please select the date or the clock in the menu bar. The background remains the same. Then use the left arrow on flux. Use the down arrow key to go to your menu command.
Here is my macro. Just change it for yourself.
Start : Stop copy.kmmacros (7,4 KB)
Rather than duplicating all those "Left Arrows", how about using the "Repeat" action, like this:
By the way, the "12" is an estimate. I'm not really sure how many you have in your macro. I can't count higher than 3.
Thanks for the tip @DanThomas. I have only been here for a few months and I am grateful for any improvement. I can spare a lot of work with it
Youâre welcome. We all learn as we go. Thatâs one of the reasons I try to at least skim all the posts - you never know what youâll learn!
Glad to help.
Have you seen the topic about accessing menulets?
In particular my post about the f.lux menu:
This will/should do it:
_Flux Menu - Preferences.kmmacros (2.3 KB)
###Notes:
-
The whole stuff with âtimeoutâ and âkillall System Eventsâ was necessary because of a strange delay caused by the first AXPress. I didnât find a better way to work around it. Credits to Aviral Bansal for the âkillallâ idea.
-
In case you modify the script, attention with the ellipsis in âPreferences...â: these are three separate dots, not the ellipsis character.
-
If it doesnât work set the timeout to 0.2 or 0.3, etc.
Edit (2017-01-19):
I have posted a more complete standalone version of the script over at the f.lux forum.
Thanks for sharing this tip, @Tom. I think your technique may be helpful in dealing with similar issues trying to control the UI of KM Status Menu.
Instead of the combination of âtryâ and âtimeoutâ you could also use âignoring application resultsâ, but this worked for me only in a standalone script (launched from SD or FastScripts), but not via KM.
Again many many thanks for the tip @DanThomas. I have modified all my macros accordingly
It shouldnât be a problem. This works for me on my macOS 10.12.2 system.
With this sort of brute-force approach timing issues are likely, and it may be necessary to use pauses appropriately to let the UI catch up to Keyboard Maestro.
Flux ⢠Disable for an Hour.kmmacros (6.0 KB)
This is very acceptably quick on my machine.
NOTE: People should complain in droves to the developer of Flux and to Apple about the poor/buggy support for accessibility.
-Chris
Nope. Weird. I tried your macro and itâs the same as with my macro above: It works only with the try & timeout in the AppleScript:
tell application "System Events"
tell application process "Flux"
tell menu bar 1
tell menu bar item 1
try
with timeout of 0.1 seconds
perform action "AXPress"
end timeout
end try
end tell
end tell
end tell
end tell
The âignoringâ version does not open the menu. (But it does when launched from SD.)
KM 7.3.1 and OS 10.12.3 Beta (16D30a) here.
Maybe the 10.12.3 makes the difference, but I donât really believe. Maybe some differences in KMâs settings?
Hmm... More likely the former than the latter.
Your script above works fine here too, although I've reduced the timeout to 0.001 seconds.
-Chris
Reducing the timeout to anything below 0.1 instant-crashes my ScriptDebugger (6.0.3 (6A191)).
Edit: Doing so in KM does not crash, but it brings back the 5s-delay. The lowest I can go on my machine is 0.02 seconds.
Hey Tom,
That doesn't happen in Script Debugger 5.x. I've reported this to Mark via the crash-reporter.
Curious...
-Chris
Finally a reason to get a new and faster Mac
Hey, I have found it!
System Events was unchecked in the Accessibility Privacy settings:
Now also in KM both methods work. I have no clue why and since when it was unchecked. And the weird thing is that all of my other UI scripts were working, and that it affected the âignoring application responsesâ only when launched from KM.
Hey Tom,
Very odd â good job finding the problem!
-Chris
Hey Tom,
I would like to experiment with this shell script "killall System\ Events" but i can't find the script itself nowhere. Maybe i am overlooking something obvious, but i guess i have to install it in /usr/local/bin/, right?