Jump to content
dfay

Finder scripts (including opening in a single window)

Recommended Posts

@dfay I was tinkering around with the Active Windows workflow, and I noticed that a small tweak to the "active_window.scpt" helped it start working with the OmniOutliner app.

 

Namely, if you remove the "document" reference when you're grabbing the app/name/id, it seem to work. I've copied the relevant version of the script below, commented out the original line, and added a notation to the new line in screenshot below.

 

	set theWindows to {}
	set appsForWindows to {}
	repeat with theApp in appList
		tell application theApp
			set itsWindows to every window
			repeat with w in itsWindows
				#set theWindows to theWindows & {{theApp as string, name of document of w, id of w}}
				set theWindows to theWindows & {{theApp as string, name of w, id of w}} -- Added by Jason
			end repeat
		end tell
	end repeat

 

I still haven't had any luck getting it to work with PDF Expert, but I'll keep toying with it. Do you ever use this app? Unfortunately, I suspect that it's not scriptable.

 

All the best!

Share this post


Link to post
Posted (edited)

Cool, thanks - I expect there will be a lot of similar quirks depending on how apps extend the base classes in applescript, but haven’t had the time to do further testing etc.

 

Unfortunately Readdle seems to have no interest in making their apps scriptable - I had a brief email exchange with them after PDF Expert beta for Mac launched & they’ve done nothing since.  

Edited by dfay

Share this post


Link to post

@dfay Unfortunately, my previous suggestion had the unintended side-effect of retaining the page info from Preview - which takes up a ton of space in the output (e.g., page 1 of 350, etc.). To fix this, I just added an IF/THEN statement to use the original code for Preview's windows, and the abbreviated version for other things. I don't have Skim on my machine, so I didn't add anything special for it. I suspect that you'll want to treat it like Preview (i.e., the original code)?

 

Here's the relevant portion of the "active_window" script:

 

	set theWindows to {}
	set appsForWindows to {}
	repeat with theApp in appList
		tell application theApp
			set itsWindows to every window
			repeat with w in itsWindows
				if ((theApp as string) is equal to "Preview") then -- Added by Jason
					set theWindows to theWindows & {{theApp as string, name of document of w, id of w}}
				else -- Added by Jason
					set theWindows to theWindows & {{theApp as string, name of w, id of w}} -- Added by Jason
				end if -- Added by Jason
			end repeat
		end tell
	end repeat

 

Yeah, you're definitely right about PDF Expert. I asked them about a different script-related question previously, and got brushed off. I don't think they'll ever add it. That issue seemed like it was a little more complicated than grabbing a document/window's name, however. I'm a little surprised that it doesn't work here. Isn't that limited amount required? In any case, maybe I'll have to switch to another PDF reader/annotater some day. For the most part, I use Preview. However, I've always liked the simplicity and aesthetic of PDF Expert better - so I use it when I'm reading for longer periods. Its layout for annotations and bookmarks is a lot cleaner than Preview's. I also have Adobe Acrobat Pro DC and Abby FineReader, but I'm not a big fan of these apps when just reading or taking notes.

 

I assume from the script that you're a Skim user, right? Out of curiosity, what do you do about the embedded annotations issue (assuming it's still an issue)? I never tried Skim because I hated the idea of having to remember to export each PDF after adding something to it. It's GUI always struck me as a little dated, too (but functional, nonetheless).

 

Unrelated, but were you thinking about displaying each supported app's icons in the workflow's output? I ask because I noticed the images in the workflow's folder (and think it's a good idea, too). However, they've never shown up on my computer - even before I started screwing around with it. My output just shows the generic orange four squared icon from Alfred for all windows/apps.

Share this post


Link to post

@dfay By chance, do you know how to target Finder's "All Tags.." view (accessible most easily through the sidebar, when enabled)? I tried to create a simple workflow that opened Finder to this view, and have not had any luck. It seems to behave quite differently from most. Thanks

Share this post


Link to post

I've used Skim since 2005, before Preview added annotations, so it's largely a matter of inertia.  But it also has better AppleScript capabilities for getting notes out than anything else I've tried

 

I was trying to get the app icons but they weren't showing up despite using (what I think was) the correct json.  So I gave up and used the generic 4 square icon.

 

The "All Tags..." control would need to be addressed through GUI scripting.  I tried a bit with no success.

Share this post


Link to post

@dfay Thanks for giving it a try! I really appreciate it.

 

I'm not sure what the deal is with Mojave's tags features. Even the old tags shortcut doesn't work without removing favorites or other odd workarounds. Let's keep our fingers crossed they address some of this in Catalina. ... I won't hold my breath.

Share this post


Link to post

Hi, I love the FineReader workflow to auto OCR docs. I noticed the workflow works on the Web-downloaded version. How can I get it to work on the Mac-Downloaded version. When I run the scrip on the Mac-downloaded version I get the below error:

Error -1728 : System Events got an error: Can’t get file "Macintosh HD:Users:

 

I would love if you guys can give me a hand?

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...