Re: Testing for last process used
Re: Testing for last process used
- Subject: Re: Testing for last process used
- From: kai <email@hidden>
- Date: Wed, 11 Jan 2006 15:55:18 +0000
On 10 Jan 2006, at 04:02, Brett Conlon wrote:
Is there a way to test for the last process used?
I see that you're already considering UI scripting for this, Coj -
but I'll throw the following into the pot anyway, FWIW:
-------------------
to getLastProcess()
tell application "System Events"
tell (get first process whose frontmost is true)
set visible to false
repeat while visible
delay 0.1
end repeat
end tell
set lastProcess to name of (get first process whose frontmost is true)
if lastProcess is "Finder" and (count (processes whose visible is
true)) > 1 then
tell process "Finder"
set visible to false
repeat while visible
delay 0.1
end repeat
end tell
set lastProcess to name of (get first process whose frontmost is
true)
ignoring application responses
set process "Finder"'s visible to true
end ignoring
end if
end tell
lastProcess
end getLastProcess
set lastProcess to getLastProcess()
tell application lastProcess to display dialog "Process \"" &
lastProcess & "\"" (* demo *)
-------------------
That obviously assumes your script doesn't want to target Finder. If
it does, then the handler could be abbreviated to:
-------------------
to getLastProcess()
tell application "System Events"
tell (get first process whose frontmost is true)
set visible to false
repeat while visible
delay 0.1
end repeat
end tell
name of (get first process whose frontmost is true)
end tell
end getLastProcess
set lastProcess to getLastProcess()
tell application lastProcess to display dialog "Process \"" &
lastProcess & "\"" (* demo *)
-------------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden