I wanted a macro that will open/close a Finder folder/window. Since KM couldn't do that on it's own I created an Applescript;
Note: "scans~ƒ" is the name of the folder in question which resides on the desktop. There are many variations to this script but this one is easier to follow.
--<Script>
(* scansFolder.app - 4/13/15 - By R L Poland
*)
set scansFolder to (path to desktop as text) & "scans~ƒ" as alias
tell application "Finder"
set windowList to name of Finder windows as text
if windowList contains "scan" then
close window "scans~ƒ"
else
open folder scansFolder
end if
end tell
--</Script>
Hey Bob,
Any special reason you’re using an AppleScript applet instead of a .scpt or .scptd file?
–
Best Regards,
Chris
I didn’t know anything else would work.
Hey Bob,
You can run normal .scpt and .scptd compiled scripts, applets, and text scripts — KM is pretty flexible.
-ccs
Hey Bob,
As it happens Keyboard Maestro can do this little job, although it's not nearly as simple as it is with AppleScript.
Toggle Finder Window Open:Closed.kmmacros (7.0 KB)
Note that I'm not using the same folder-path you are, so you'll have to change to suit.
Note also that I am not bothering to restore the front application, although this is possible.
--
Best Regards,
Chris