Re: frontmost application... :(
Re: frontmost application... :(
- Subject: Re: frontmost application... :(
- From: Jean-Christophe Helary <email@hidden>
- Date: Tue, 23 Apr 2019 10:49:39 +0900
Yves,
Thank you very much.
I was looking for something like a "z" index in the processes where I could
pick the "second" when there is only frontmost or not, and it just did not
occur to me that frontmost could also be considered as a z index...
And the repeat block to wait until the script is sent to the background is
really nice.
Those are 2 ideas I'll use in other scripts !
In the case at hand, the script I'll launch will be a script application,
launched from Spotlight so I figured that a simplified version like:
tell application "System Events" -- get frontmost process
set frontmostProcess to first process where it is frontmost -- this
will be the script process
set visible of frontmostProcess to false -- hide the script process
repeat while (frontmostProcess is frontmost) -- wait until the script
is hidden
delay 0.1
end repeat
set theApp to name of first process where it is frontmost -- get name
of frontmost process (ignoring the script process)
set frontmost of frontmostProcess to true -- unhide the script process
display dialog theApp
end tell
would work too. Would there be things that possibly interfere with the
process(es) so that the script application ends up not being frontmost after
launch ?
Jean-Christophe
> On Apr 23, 2019, at 3:00, Yvan KOENIG <email@hidden> wrote:
>
> In such case, I use this kind of code:
>
> tell application "System Events" -- get frontmost process
> set frontmostProcess to first process where it is frontmost --
> this will be the script process
> if name of frontmostProcess is in {"Script Editor",
> "AppleScript Editor", "Script Debugger"} then
> set visible of frontmostProcess to false -- hide the
> script process
> repeat while (frontmostProcess is frontmost) -- wait
> until the script is hidden
> delay 0.1
> end repeat
> set theApp to name of first process where it is
> frontmost -- get name of frontmost process (ignoring the script process)
> set frontmost of frontmostProcess to true -- unhide the
> script process
> else
> set theApp to name of frontmostProcess
> end if
> end tell
>
> Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi
> 22 avril 2019 19:59:59
>
>> Le 22 avr. 2019 à 18:08, Jean-Christophe Helary <email@hidden
>> <mailto:email@hidden>> a écrit :
>>
>> tell application "System Events"
>> tell (process 1 where frontmost is true)
>> set myName to its name
>> display dialog myName
>> end tell
>> end tell
>>
>> Obviously, I get the name of the script, when I want the name of the
>> application that's frontmost before I launch the script... :(
>>
>> Ultimately, I just want to get the path of the frontmost document of the
>> frontmost application...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden