Detect background application...

Sarah Reichelt sarah.reichelt at gmail.com
Tue Jun 8 21:00:08 EDT 2010


On Wed, Jun 9, 2010 at 10:53 AM, Simon Lord <slord at karbonized.com> wrote:
> Is there a way to have a stack know if it's not *focused*?  Can this
> also be done if the stack is not the foreground application?


On a Mac, you can do this using AppleScript.
Here are my handlers for this:

function isAppAtFront pAppName
    if isAppRunning(pAppName) = false then return false

    put " tell application " & quote & "System Events" & quote & cr & \
            	"get the frontmost of application process" & quote &
pAppName & quote & cr & \
            "end tell" into tScript

    do tScript as AppleScript
    return the result
end isAppAtFront

function isAppRunning pAppName
    put "tell application " & quote & "System Events" & quote & cr into tScript
    put "return (exists application process " & quote & pAppname &
quote & ")" & cr after tScript
    put "end tell" after tScript
    do tScript as AppleScript
    return the result
end isAppRunning

-- 
Cheers,
Sarah

Rodeo discussion:
http://rodeoapps.com/rodeo-discuss-among-yourselves



More information about the use-livecode mailing list