Hi,
I have an AppleScript Studio app I am working on. I would like to perform an action when the application becomes the active app. Forgive me for my lack of knowledge, but what handler can I use to perform an action when the application becomes the frontmost one? Thanks.
In IB attach the “activated” handler under the “Application” section of the AppleScript tab of the “Get Info” palette to the File’s Owner (the application). Then, in your script, add this code:
on activated the_object
--do something
end activated
Jon
Thanks jonn8, but I am at a bit of a quandry here, and maybe this isn’t even possible, but the situation I have is that I want the activated handler to do two things. Bring a separate app to the front and then bring my AppleScript Studio app to the front. This way if a user goes off and does something else in another program, simply clicking on the AppleScript Studio app’s window brings things back to normal app layering, etc. Of course, when I bring the AppleScript Studio app to the front (with an activate me command), I am initiating the on activated handler again, resulting in an endless loop.
Try this (substituting the name of the secondary app for “Safari”, of course):
on activated the_object
set my_name to name of me
tell application "System Events"
set frontmost of process "Safari" to true
set frontmost of process my_name to true
end tell
end activated
Jon