Sunday, November 23, 2014

#1 2011-12-24 01:39:52 pm

jsherk
Member
Registered: 2011-12-24
Posts: 18
Website

AppleScript questions: speed it up with xcode? miniaturized property?

Hi

I am new to Mac (Lion 10.7.2), and am playing around with AppleScript. I have the following script that minimizes all visible windows:
Code:

Applescript:

tell application "System Events"
   --Get all the available applications that can be visible
   repeat with appProc in (every application process whose visible is true)
       --From the available applications above, click on the minimize
       -- button of every window that has a minimize button
       click (first button of every window of appProc whose role description is "minimize button")
   end repeat
end tell

Here are my problems and quesions...

The script does work, except it is kind of slow, meaning instead of instantly minimizing all the windows, you watch each one get minimized one by one. I tried saving it as an application from AppleScript Editor, but then it is really really slow (takes about 5 to 10 seconds before it even starts doing anything).

QUESTION #1
Can this script be imported into Xcode and be converted to an app that will run much faster?

QUESTION #2
I was looking for other ways to do this instead of "click button", and I found references to the miniaturized property of the window, but this property and the miniaturizable property both do not appear to exist when I view the properties of applications and windows. I have searched google for hours about this, and cannot figure out why it is not availble.

----------
Questions #3 and #4 I was about to ask, but found answers a few minutes ago, and thought I would post because they are related:

ANSWERED QUESTION #3
How can I create an alias on the desktop (to the .scpt file), that when clicked, will run the script instead of opening it up in AppleScript Editor? I do not want to the Script Menu in the menu bar to run the script.

ANSWERED QUESTION #4:
Can AppleScript be iimported into Automator and converted to an application?

ANSWER for Question #3 and #4:
Start Automator, choose new Application and then drag the Run Applescript Action over to the right hand side and then copy and paste your applescript into it and save it. You now have an application that runs just as fast as the original applescript, and you can also create an alias on your desktop to it.

Thanks

Offline

 

#2 2011-12-26 07:51:00 am

DJ Bazzie Wazzie
Member
From: the Netherlands
Registered: 2004-10-20
Posts: 2002

Re: AppleScript questions: speed it up with xcode? miniaturized property?

QUESTION #1
Can this script be imported into Xcode and be converted to an app that will run much faster?

Yes this can be imported into an AppleScriptObjC project but I doubt it will be faster than an 'execute-only' script.

QUESTION #2
I was looking for other ways to do this instead of "click button", and I found references to the miniaturized property of the window, but this property and the miniaturizable property both do not appear to exist when I view the properties of applications and windows. I have searched google for hours about this, and cannot figure out why it is not availble.

Can't you just hide the application instead? or need every window to be in the dock per se?

ANSWERED QUESTION #3
How can I create an alias on the desktop (to the .scpt file), that when clicked, will run the script instead of opening it up in AppleScript Editor? I do not want to the Script Menu in the menu bar to run the script.

It's not an alias, you need to save the script as an application or execute only script or script bundle to run instead of opening in script editor. NOTE: applications can be opened (when execute only flag is off) by opening the file from the open menu or dragging it onto the application. When the execute-only flag is turned on you can't open them after you've closed the document.


Kind regards

Offline

 

#3 2012-03-21 12:18:42 am

jsherk
Member
Registered: 2011-12-24
Posts: 18
Website

Re: AppleScript questions: speed it up with xcode? miniaturized property?

Somebody finally figured out how to Show Desktop correctly:
http://www.everydaysoftware.net/showdesktop/index.html

Offline

 

#4 2012-03-21 02:29:19 am

alastor933
Member
From: Utrecht, NL
Registered: 2008-09-12
Posts: 458

Re: AppleScript questions: speed it up with xcode? miniaturized property?

jsherk wrote:

Somebody finally figured out how to Show Desktop correctly:
http://www.everydaysoftware.net/showdesktop/index.html

Exposé has done that since 10.5, I think - F11, or fn-F11 on an alu keyboard.
In 10.7 (which I do not have) those functions are now in Mission Control.

Offline

 

#5 2012-03-21 09:07:05 am

jsherk
Member
Registered: 2011-12-24
Posts: 18
Website

Re: AppleScript questions: speed it up with xcode? miniaturized property?

No, Expose and Mission Control do NOT do it properly (well not the way I want it done) .. they just move everything to the outside edges.

With the script above, it hides/minimizes all windows instantly, which is different than how OS X has tried to do it.

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.021 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)