Sunday, May 31, 2020

#1 2012-02-15 01:39:00 pm

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 640
Website

window area focus

I know that 'Preview' isn't scriptable (i'm on OS 10.6). But sometimes you can get pretty nice results coding some workarounds.
So, my questions is if i can get any infos on which window area application 'Preview' is currently focused:
> main window area
> column area (cmd+shift+d)

my first approach is :

Applescript:

tell application "System Events" to tell process "Preview"
       set nrw to number of windows
       if nrw > 0 then
           tell window 1
               --properties
           end tell
       end if
end tell

but then i need to work with raw code, where i'm not practical. Some hints?

Offline

 

#2 2012-02-15 02:30:07 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4666

Re: window area focus

Something like this for size -- column width is not available among the properties

Applescript:

tell application "System Events" to tell process "Preview"
   activate
   set nrw to number of windows
   if nrw > 0 then
       tell window 1
           set SZ to size
       end tell
   end if
end tell


Mac mini running 10.14.6, 2011 27" iMac as display.

Offline

 

#3 2012-02-16 03:29:23 pm

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 640
Website

Re: window area focus

Hi Adam,
thanks nevertheless. Not that i get fancy to code for non-scriptable apps, but have you an idea where i can study a bit of raw-coding ? i remember you wrote a very useful tutorial about mdfind using raw-code in another situation. I think, in my case is unlikely that i'll find something useful to solve my problem. This time its really too nested stuff…

Offline

 

#4 2012-02-20 03:58:55 am

Chocoholic
Member
Registered: 2012-01-31
Posts: 21

Re: window area focus

Get the focussed element of the application and get it's parent until you get the main window area or the column area.

Applescript:

tell application "System Events"
   tell application process "Preview"
       if number of windows < 1 then
           return "Application"
       end if
       tell splitter group 1 of window 1
           if number of scroll areas = 1 then
               -- the column area isn't visible
               return "Main window area"
           end if
           set mainWindowArea to scroll area 1
           set columnArea to scroll area 2
       end tell
       set anElement to value of attribute "AXFocusedUIElement"
       repeat
           if anElement = mainWindowArea then
               return "Main window area"
           else if anElement = columnArea then
               return "Column area"
           else if anElement = it then
               return "Application"
           end if
           set anElement to value of attribute "AXParent" of anElement
       end repeat
   end tell
end tell

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)