cwd
cwd

Reputation: 54776

Applescript to Expose all Finder Windows?

I'm trying to figure out how to write an Applescript that will Exposé all Finder Windows.

Application Logic

I think the script needs to have this application logic:

Desired Behavior

I'm not sure how to get this working though. If there is another utility that does this automatically that'd be great, too.

enter image description here

Upvotes: 0

Views: 695

Answers (1)

Lri
Lri

Reputation: 27613

set f to "/s/x/finderexpose"
set prev to do shell script "touch " & f & "; cat " & f
if prev is not "" then
    delay 0.5 -- time to release modifier keys used in a shortcut
    tell application "System Events" to key code 53 -- esc, if Exposé is open
    delay 0.3 -- for the Exposé animation?
    activate application prev
    do shell script "echo '' > " & f
else
    do shell script "echo " & quoted form of (path to frontmost application as text) & " > " & f
    activate application "Finder"
    delay 0.05
    tell application "System Events" to key code 125 using {control down} -- ⌃↓
end if

It'd be less ugly if the part for switching to the previous application was left out:

activate application "Finder"
delay 0.05
tell application "System Events" to key code 125 using {control down}

Upvotes: 1

Related Questions