How can I trigger a macro every time the mac unlocks? The triggers login and wake don't exactly get triggered on unlocks.
Thanks in advance.
How can I trigger a macro every time the mac unlocks? The triggers login and wake don't exactly get triggered on unlocks.
Thanks in advance.
There is no trigger for when the Mac unlocks. I’m not sure what combination of triggers you could use, perhaps the front window changed trigger. There is also no direct way to tell if the Mac is locked, though it may be possible with a script.
You can use another software called EventScripts (I’m not sure if I can mention other software here. If no, I will delete the post). And then use AppleScript to execute a macro in that software. This combination works fantastic to me.
Don't worry about that. Peter's not particularly insecure. :smile:
Looking at the examples it does appear there are triggers for:
Screen password locked
Screen password unlocked
-Chris
Thank you for the answers, it worked really well!
Hey @peternlewis, I was looking to do the above because I have Wi-Fi turn off when Mac goes to sleep to prevent battery use when the Macbook eventually wakes up in my backpack. Wanted Wi-Fi back on on system wake, but Keyboard Maestro's on-wake event was turning it on even if the screen opened a tad (eg in my backpack ) so it defeated the purpose! I wanted Wi-Fi back on only after successfully unlocked the Mac (and on-login would be triggered only on initial login).
I bought Eventscripts and made it work:
...but hoping you might add that event in Keyboard Maestro so I (and others) don't have to run another app?
Hi @ajg23, since I'm not very familiar with creating an AppleScript, I would be very grateful if you could share your "Wi-Fi on" script.
I have this AppleScript—no idea now where I found it—that enables or disables WiFi. I'm running 10.11.6 so I can't confirm if it works on later versions of macOS.
-- Toggle Airport Power On and Off
--
if (offset of "On" in (do shell script "networksetup -getairportpower en0")) > 0 then
do shell script "networksetup -setairportpower en0 off"
else
do shell script "networksetup -setairportpower en0 on"
end if
Edit: Code source: Mac OS X Hints
Wake can happen at all sorts of times, even if the Mac is closed.
There is currently no trigger for unlocking the screen in Keyboard Maestro.
I'm glad you found a solution.
Thanks a lot @NaHo for sharing the script @NaOH You helped me a lot with it.
This is done for the next major version.