Monday, December 18, 2017

#1 2017-07-23 01:02:20 pm

DPaquin
Member
Registered: 2012-01-23
Posts: 69

Loops through opened windows and re-position them (DASHBOARD)

Hello,

I want to look at all windows that are currently opened. Loop through all of them and those with a specific name they are to be reposition on the screen.

The idea is to create some kind of dashboard for people to execute their tasks. I am taking into account that people never worked with a MAC. Therefore do not know of to open/reposition/minimise/close a window.

The idea is when going through the loop if a window with a specific name appears, make it active and re-position it.

Here is what I've been trying to work with. At the moment the window name I am interested are : 101PNV01, SAUVEGARDE and MPEGfiles. The dashboard will be made of about 8 different windows.

- One FileMaker Pro application window
- Two  SAFARI windows
- Five FINDER windows

At the moment, for some reason all windows name are equal to "101PNV01"

Applescript:

tell application "System Events"
   set theProcesses to application processes whose visible is true
   repeat with theProcess from 1 to count theProcesses
       tell process theProcess
           repeat with x from 1 to (count windows)
               tell application "Finder"
                   activate
                   tell the front window to set toolbar visible to false
                   if name of front window is equal to "101PNV01" then
                       display dialog "101PNV01"
                       set bounds of front window to {953, 23, 1280, 401}
                   else if name of front window is equal to "SAUVEGARDE" then
                       display dialog "SAUVEGARDE"
                       set bounds of front window to {952, 401, 1280, 796}
                   else if name of front window is equal to "MPEGfiles" then
                       display dialog "MPEGfiles"
                       set bounds of front window to {952, 301, 1280, 547} -- MPEGfiles
                   end if
               end tell
           end repeat
       end tell
   end repeat
end tell

I get to see all opened windows when I run this command alone

Applescript:

tell application "System Events" to get the properties of every window of (every process whose visible is true)

Thanks!

Daniel

Last edited by DPaquin (2017-07-23 02:43:24 pm)


Filed under: Dashboard

Offline

 

#2 2017-08-01 11:32:34 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 211

Re: Loops through opened windows and re-position them (DASHBOARD)

I have no help for you at the moment, but the code in your question actually provides useful insight into an unanswered question of mine, so thanks for that!

http://macscripter.net/viewtopic.php?id=45661


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#3 2017-08-01 01:08:03 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3203

Re: Loops through opened windows and re-position them (DASHBOARD)

You may try :

Applescript:

tell application "System Events"
   set theProcesses to application processes whose visible is true
   repeat with theProcess from 1 to count theProcesses
       tell process theProcess
           repeat with x from 1 to (count windows)
               tell application "Finder"
                   activate
                   set windowX to window x
                   tell windowX to set toolbar visible to false
                   set nameX to name of windowX
                   if nameX is equal to "101PNV01" then
                       display dialog "101PNV01"
                       set bounds of windowX to {953, 23, 1280, 401}
                   else if nameX is equal to "SAUVEGARDE" then
                       display dialog "SAUVEGARDE"
                       set bounds of windowX to {952, 401, 1280, 796}
                   else if nameX is equal to "MPEGfiles" then
                       display dialog "MPEGfiles"
                       set bounds of windowX to {952, 301, 1280, 547} -- MPEGfiles
                   end if
               end tell
           end repeat
       end tell
   end repeat
end tell

In your original code we loop among the list of indexes but you grabbed always datas from the front window which doesn't change in the loop.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 1 aout 2017 20:07:54

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)