Good point. Tried that and, unfortunately, it didn't work. I have a feeling it's not possible to get this working in fullscreen but I might be proven wrong yet.
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!
|
|
FAQ | Members List | Calendar | Today's Posts | Search |
Script: Zoom all canvases to fit whole diagram | Thread Tools | Search this Thread | Display Modes |
Member
2011-12-23, 04:03 PM
Good point. Tried that and, unfortunately, it didn't work. I have a feeling it's not possible to get this working in fullscreen but I might be proven wrong yet.
Post 11
|
Guest
2011-12-27, 10:08 AM
FWIW a quick check on a Lion machine that crossed my desk this afternoon suggested that the Fullscreen window may appear to Applescript as Window 2 of the OG app.
Post 12
|
Member
2011-12-28, 08:47 AM
Thanks for that info. I have to admit that my knowledge of AppleScript is shallow at best, so I may be doing something wrong here. I tried modifying the fullscreen function to the following:
Code:
-- Checks whether an application is in full screen mode in Lion on isFullScreen(strAppCode) try tell application id "sevs" set lstApps to application processes where its creator type = "OGfl" if length of lstApps < 1 then return missing value tell first item of lstApps set oWin to missing value try set oWin to second window end try if oWin is not missing value then tell oWin repeat with oCanv in canvases of its document set canvas of it to oCanv -- ZOOM TO FIT tell application id "sevs" to click mnuZoomFit end repeat end tell end if end tell end tell on error return false end try end isFullScreen
Post 13
|
Guest
2011-12-28, 02:09 PM
I think it would need to work something like this:
Code:
-- ZOOM ALL CANVASES IN CURRENT OMNIGRAFFLE DOCUMENT TO FIT WHOLE DIAGRAM property pTitle : "Zoom All Canvases to Fit" property pVer : "1.0" property plstMenuItem : {"View", "Zoom", "Fit in Window"} on run if not GUIEnabled() then return -- GET A REFERENCE TO VIEW > ZOOM > FIT IN WINDOW set mnuFitWindow to GetMenuItem("OGfl", plstMenuItem) -- LOOP THRU EACH CANVAS -- OF THE FRONT WINDOW OR FULL-SCREEN WINDOW tell application id "OGfl" activate if my isFullScreen("OGfl") then set oWin to window 2 else set oWin to window 1 end if tell oWin try set oFrontCanvas to its canvas on error return end try repeat with oCanv in canvases of its document set canvas of it to oCanv -- CLICK ZOOM TO FIT IN WINDOW tell application id "sevs" to click mnuFitWindow end repeat set its canvas to oFrontCanvas end tell end tell end run -- RETURNS A REFERENCE TO A CLICKABLE MENU ITEM -- E.G. set mnuZoomFit to GetMenuItem("OGfl", {"View", "Zoom", "Zoom to Selection"}) on GetMenuItem(strAppCode, lstMenu) set lngChain to length of lstMenu if lngChain < 2 then return missing value tell application id "sevs" set lstApps to application processes where its creator type = strAppCode if length of lstApps < 1 then return missing value tell first item of lstApps -- GET THE TOP LEVEL MENU set strMenu to item 1 of lstMenu set oMenu to menu strMenu of menu bar item strMenu of menu bar 1 -- TRAVEL DOWN THROUGH ANY SUB-MENUS repeat with i from 2 to (lngChain - 1) set strMenu to item i of lstMenu set oMenu to menu strMenu of menu item strMenu of oMenu end repeat -- AND RETURN THE FINAL MENU ITEM return menu item (item -1 of lstMenu) of oMenu end tell end tell end GetMenuItem on GUIEnabled() tell application id "sevs" if UI elements enabled then return true else activate display dialog "This script depends on enabling access for assistive devices in system preferences" buttons "OK" default button "OK" with title pTitle & " " & pVer tell application id "sprf" activate set current pane to pane id "com.apple.preference.universalaccess" end tell return false end if end tell end GUIEnabled on isFullScreen(strAppID) tell application "Finder" to set blnPreLion to (version < "10.7") if blnPreLion then return false else tell application id "sevs" set lstApps to application processes where creator type = strAppID if length of lstApps < 1 then return false set lstWins to windows of first item of lstApps if length of lstWins < 1 then return false return value of attribute "AXFullScreen" of item 1 of lstWins end tell end if end isFullScreen Last edited by RobTrew; 2011-12-29 at 10:43 AM.. Reason: Edited code: Finder version is faster than sysinfo system version
Post 14
|
Member
2011-12-29, 10:12 AM
Very nicely done! This works like a charm. Both in fullscreen and normal windowed mode. Apart from getting a useful script, this is a nice tutorial in some of the workings of AppleScript, so again, thanks for your help.
Post 15
|
Member
2013-01-24, 02:36 PM
I would love to set zoom levels as well, can this script be modified to do that?
Thanks!
Post 16
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Global zoom level for multiple canvases | chrishan | OmniGraffle General | 6 | 2013-01-24 03:22 PM |
Script: Export from FoldingText outline to OmniGraffle diagram | RobTrew | OmniGraffle General | 0 | 2012-10-04 12:44 PM |
how do I break process diagram into separate pages and display diagram name on every page | Chien | OmniGraffle General | 0 | 2012-04-25 06:38 AM |
Is there any way to set zoom across multiple canvases? | fjordaan | OmniGraffle General | 7 | 2011-08-24 05:32 AM |
multiple master canvases, new canvases | wynntemp | OmniGraffle General | 2 | 2009-02-23 01:44 PM |