I'm not quite sure where this action/script came from (the AppleScript looks more complex than one I would write), but I use it all the time and its very handy. It gets the path of the front window in Preview. It should work in pre 10.9, but 10.9 or later is much easier since Preview regained its AppleScript dictionary, so the simple AppleScript:
path of document 1 of window 1 of application "Preview"
is all you really need, but packaged as a plug in is still a bit nicer.
Yes, Keyboard Maestro uses .zip as a package format for Third Party Plug In Actions as well as Status Menu Icons. I could use a different extension, but that is similarly confusing when it’s just a zip file.
That looks like something I wrote long ago and scarfed the vanilla decode routine from here, but I won’t swear up and down.
You can make it generic to the front application easily enough:
tell application (get path to frontmost application as text) to set frontApp to its name
tell application "System Events"
tell process frontApp
set thefile to value of attribute "AXDocument" of (first window whose subrole is "AXStandardWindow")
if thefile ≠ missing value then
urldecode(POSIX path of POSIX file thefile)
error "No file has been saved!"
# Content omitted
More recently I’d shell out to Perl, Python, or Ruby to do the decode, but at this point it makes more sense to use JXA.