Is there any way to test with applescript whether the sidebar in Preview is visible/activated or not?
I have checked attributes of the relevant menubar item but it does not seem to contain this info…
Cheers
Is there any way to test with applescript whether the sidebar in Preview is visible/activated or not?
I have checked attributes of the relevant menubar item but it does not seem to contain this info…
Cheers
Hi,
try this
activate application "Preview"
tell application "System Events"
tell process "Preview"
set sideBarIsVisible to (get value of attribute "AXMenuItemMarkChar" of menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1) is "✓"
end tell
end tell
Also, You could try this
activate application "Preview"
tell application "System Events"
tell «class prcs» "Preview"
if (get name of «class menI» 1 of «class menE» 1 of «class menI» "Sidebar" of «class menE» 1 of «class mbri» "View" of «class mbar» 1) is "Hide Sidebar" then
display dialog "Preview has its Sidebar Open"
else
display dialog "Preview has its Sidebar Closed"
end if
end tell
end tell
Thats the way it compiled ?
Entered as
tell process "Preview"
if (get name of menu item 1 of menu 1 of menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1) is "Hide Sidebar" then
display dialog "Preview has its Sidebar Open"
else
display dialog "Preview has its Sidebar Closed"
end if
end tell
Val
Marvellous
Thanks for your help.
I will now work on Acrobat and Skim with same problem! If I get stuck, I know where to come to.
Again, many thanks
Andrew
I have this for Acrobat:
set navigationPaneStatus to name of menu item 14 of menu 1 of menu item "Navigation Panels" of menu 1 of menu bar item "View" of menu bar 1
It works, but seems to slow down the script tremendously, with a second or so pause. Is there a quicker way of finding out if the navigation pane is showing (or pages in sidebar). Under the menus, you can tick “Pages”, so I thought there might be something similar to what Stefan suggested for Preview which works without any noticeable lag.
Cheers
My fault. Works fine. Will revert if Skim poses problems.
Here is the result. The two scripts shifts the frontmost window between desktops/monitors. If the window belongs to Preview, Acrobat or Skim, it will resize and adjust. I have hot keys assigned to the two scripts using Quicksilver (one script named Expand Window, the other Reduce Window).
For your particular setup, you will need to adjust the numbers for the monitors/laptop you use. I use a 13" Macbook Pro (res 1280x800) and 24" external monitor (res 1920x1080). Enjoy.
--EXPAND WINDOW SCRIPT - MOVES FRONT WINDOW TO EXTERNAL MONITOR AND TOGGLES NAVIGATION PANE IN PREVIEW/SKIM/ACROBAT
tell application "Finder"
set pname to name of every process whose frontmost is true
set pname to item 1 of pname
end tell
tell application "System Events" to set numberOfDisplays to count desktops
if numberOfDisplays is greater than 1 then
tell application "System Events"
tell process pname
try
set the_pos to value of attribute "AXPosition" of window 1
set the_pos to item 1 of the_pos -- get present X axis position of window
set position of window 1 to {1280, 0}
if pname is "AdobeAcrobat" then
if the_pos is greater than 1279 then
click menu item 14 of menu 1 of menu item "Navigation Panels" of menu 1 of menu bar item "View" of menu bar 1 -- toggle show/hide navigation pane
end if
set navigationPaneStatus to name of menu item 14 of menu 1 of menu item "Navigation Panels" of menu 1 of menu bar item "View" of menu bar 1
if navigationPaneStatus is "Hide Navigation Pane" then
set size of window 1 to {1750, 1080}
else
set size of window 1 to {1500, 1080}
end if
click menu item "Two-Up" of menu 1 of menu item "Page Display" of menu 1 of menu bar item "View" of menu bar 1
delay 0.3
click menu item "Fit Page" of menu 1 of menu item "Zoom" of menu 1 of menu bar item "View" of menu bar 1
else if pname is "Skim" then
if the_pos is greater than 1279 then
click menu item 8 of menu 1 of menu bar item "View" of menu bar 1 -- toggle show/hide navigation pane
end if
set navigationPaneStatus to name of menu item 8 of menu 1 of menu bar item "View" of menu bar 1
if navigationPaneStatus is "Hide Contents Pane" then
set size of window 1 to {1700, 1080}
else
set size of window 1 to {1450, 1080}
end if
click menu item "Facing Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "PDF" of menu bar 1
delay 0.3
click menu item "Zoom To Fit" of menu 1 of menu bar item "PDF" of menu bar 1
else if pname is "Preview" then
if the_pos is greater than 1279 then
click menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1
end if
set sideBarIsVisible to (get value of attribute "AXMenuItemMarkChar" of menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1) is "✓"
if sideBarIsVisible then
set size of window 1 to {1660, 1080}
else
set size of window 1 to {1410, 1080}
end if
click menu item "Two Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "View" of menu bar 1
delay 0.3
click menu item "Zoom To Fit" of menu 1 of menu bar item "View" of menu bar 1
end if
end try
end tell
end tell
end if
And the second script…
--REDUCE WINDOW SCRIPT - MOVES FRONT WINDOW TO LAPTOP SCREEN AND TOGGLES NAVIGATION PANE IN PREVIEW/SKIM/ACROBAT
tell application "Finder"
set pname to name of every process whose frontmost is true
set pname to item 1 of pname
end tell
tell application "System Events"
tell process pname
try
set the_pos to value of attribute "AXPosition" of window 1
set the_pos to item 1 of the_pos -- get present X axis position of window
set position of window 1 to {0, 22}
if pname is "AdobeAcrobat" then
if the_pos is less than 1280 then
click menu item 14 of menu 1 of menu item "Navigation Panels" of menu 1 of menu bar item "View" of menu bar 1 -- toggle show/hide navigation pane
end if
set navigationPaneStatus to name of menu item 14 of menu 1 of menu item "Navigation Panels" of menu 1 of menu bar item "View" of menu bar 1
if navigationPaneStatus is "Hide Navigation Pane" then
set size of window 1 to {1130, 780}
else
set size of window 1 to {1130, 780}
end if
click menu item "Single Page Continuous" of menu 1 of menu item "Page Display" of menu 1 of menu bar item "View" of menu bar 1
delay 0.3
click menu item "Fit Width" of menu 1 of menu item "Zoom" of menu 1 of menu bar item "View" of menu bar 1
else if pname is "Skim" then
if the_pos is less than 1280 then
click menu item 8 of menu 1 of menu bar item "View" of menu bar 1 -- toggle show/hide navigation pane
end if
set navigationPaneStatus to name of menu item 8 of menu 1 of menu bar item "View" of menu bar 1
if navigationPaneStatus is "Hide Contents Pane" then
set size of window 1 to {830, 775}
else
set size of window 1 to {830, 775}
end if
click menu item "Single Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "PDF" of menu bar 1
delay 0.3
click menu item "Zoom To Fit" of menu 1 of menu bar item "PDF" of menu bar 1
else if pname is "Preview" then
if the_pos is less than 1280 then
click menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1
end if
set sideBarIsVisible to (get value of attribute "AXMenuItemMarkChar" of menu item "Sidebar" of menu 1 of menu bar item "View" of menu bar 1) is "✓"
if sideBarIsVisible then
set size of window 1 to {950, 790}
else
set size of window 1 to {950, 790}
end if
click menu item "Single Page Continuous" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "View" of menu bar 1
delay 0.3
click menu item "Zoom To Fit" of menu 1 of menu bar item "View" of menu bar 1
end if
end try
end tell
end tell
And if anyone knows how to trigger a Word macro using applescript, then I would build in adjustments for Microsoft Word as well.
Cheers