Howdy all. I have certain macros that run every hour and would like to tweak them a little bit.
One in particular resizes and repositions all of my work related windows as sometimes they get bumped around while doing other things.
However, since this happens automatically at different times of the day, many times I am in the process of doing something else in another window or another application entirely. What I would like is to set the current front window as a variable, minimize it, then have that window reappear on top after the macro has run.
Included is what I have tried (minus the work related macro). It works great as long as the current front window is of the same application as the last item in the macro; in this case Google Chrome since it's the last work window to be resized and repositioned. So if I'm in a separate GC window then it works fine. But if I'm in a DIFFERENT application (like Keyboard Maestro) then it doesn't work because it will only allow me to bring to front the window matching the variable in the front application which is always GC as it is the front application after macro has finished running.
What I would like is to be able to bring to front the window matching the variable in any application, or to be able to set that varuable matching window as the front application so I can then restore it.
Does anybody know if there's a way to do this or not?
Thanks for the tip. That's a neat little command to set that variable (I'm still learning variables obviously).
Unfortunately in my case it doesn't work since my macro resizes/repositions windows from multiple applications (Evernote and Google Chrome in this case). So the "Activate Last Application" command actually goes back to Evernote as it's resized/repositioned first, then GC.
Any other ideas?
Sorry about the commands snafu...I'm still new at uploading!!
OK, since your other macro may activate several other apps, then you'll need to use this script to activate the app by name:
Put This Script in a Execute AppleScript Action
### Requires Keyboard Maestro 8.0.3+ ###
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set appName to getvariable "Local__LastApp" instance kmInst
tell application appName to activate
EDIT: Never mind, I just realized I forgot to change the variable name in the Apple Script. Seems to be working now. I'll double check tomorrow at work and if I have any other issues I'll post. Otherwise thanks so much!