Hello,
I use an excellent MindManager app called Scapple which is made by the Scrivener developers.
I am writing a macro which would print to pdf and open in PDF Expert, using the scapple print dialog.
My only problem is to figure out how to specify in the macro that I always want to print in landscape mode.
Is there any action or shortcut which would allow me to specify landscape mode this in the macro ?
thanks very much for your time and help
You’re either going to have to tab to it it or else use image search.
thanks very much !
You can do that with a little AppleScript:
tell application "System Events"
tell application process "Scapple"
tell window 1
tell sheet 1
tell radio group 1
tell (first radio button whose description is "Landscape")
if value of attribute "AXValue" is not 1 then perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
Put this at the appropriate position in your macro (that is, it should run when Scapple’s Print dialog sheet is on screen).
‌
BTW, have you seen that Scapple also offers a direct PDF export? (File > Export > PDF)
It seems the PDF export only exports the part of the canvas that is populated by objects, not the whole thing. Maybe this is better for your purposes?
@Tom I prefer your solution to mine - and have similar use cases - but I have a question:
What did you do to establish what “UI Scripting” AppleScript to use?
Do you mean how I identified the UI elements (windows, buttons, etc.)?
Personally I’m using mainly Script Debugger and Accessibility Inspector, sometimes helper scripts like this or that. Many people use also UI Browser.
(Of course, instead of Script Debugger it’s also possible with Apple’s Script Editor, but quite less comfortable.)
See also these two great posts by @ccstone: One, two
Or search the forum for “ui scripting”.
But keep in mind that AppleScript UI scripting should always be the second-to-last resort, when regular AppleScript (or JavaScript) fails, for example if the target app is not “scriptable”. (The last resort would be UI scripting via KM, e.g. simulating Tab keys or searching for images and simulating clicks on them.)
I am very grateful to both of you for your answers.
Tom's solution works perfectly, and I implemented it.
@MartinPacker out of intellectual curiosity, I was playing around in the print dialog box after reading your solution, just to see if I could find a 'manual' solution, but could not figure out how to toggle between portrait and landscape after tabbing down to portrait. I tried all types of keys (spacebar, etc) to no avail. There must be a simple keystroke to toggle.
-
to answer your question, because I usually crop the resulting pdf (scapple being a canvas) and prefer that the print open directly into a pdf (via print → pdf → open pdf app and load file) rather than export → save file → pathfinder → find and open file
-
I was impressed by your solution with scapple and would like to implement it with the 'snagit 2018' app because I snagit, I am constantly alternating between portrait and landscape print. I took your script and replaced scapple with snagit 2018 and tried to use it in page setup, but it did not work, probably because your script is designed for the print dialoag.
So I want to page setup → landscape → print → page setup → portrait (to default back to printing in portrait mode).
My question is whether your script could be modified to work in Page Setup as per image below
Could you suggest a site to learn about apple scripts ?.
thanks again VERY MUCH!
Yeah, that’s exactly why I mentioned the Export. Scapple’s PDF Export (via File > Export) exports only the populated area of the canvas. In other words, it crops it automatically.
I don’t use SnagIt, so I can’t help you much here.
I tried my script from above with Scapple’s Page Setup sheet and there it works without any modification.
Check the links I posted above in my reply to @MartinPacker, especially the posts by @ccstone. They show you how to identify the UI elements.
You can use my script as a starting point. But, telling from your screenshot, it seems the SnagIt Page Setup is not a sheet but rather a window. So the first thing to do would be to eliminate the sheet part in my script.
IIRC, @JMichaelTX is a SnagIt user; maybe he can help you.
BTW: In Scapple, if you set the Page Setup to Landscape then the Print dialog automatically defaults to Landscape too. So, this would be an alternate way to get a Landscape print, depending on what fits better with your macro workflow.
OK, this one here works with the Page Setup dialog window of Microsoft Word. Try it with SnagIt (replace the process name in line 2):
tell application "System Events"
tell application process "Microsoft Word"
tell window 1
tell radio group 1
tell (first radio button whose description is "Landscape")
if value of attribute "AXValue" is not 1 then perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
Note: I added the value check for the button also to the Scapple Print dialog script above. Please use the new version!
(Without value check the script would deselect an already selected Landscape button.)
works perfectly. thanks very much !
good point: yes you are right !
great references. Thank you
I've been trying to use the scripts shown here in Excel, but without any success; the following script, adapted from those shown & others found on this topic, gives me an error saying "can't get radio group 1 of window 1" etc. I used UI Browser to get the names of the objects within the Excel print window. Can anyone see my error?