How do you rerun an open application. I tried this:
on applicationShouldHandleReopen_hasVisibleWindows_(theApplication, aFlag)
display dialog "reopen"
run
return YES -- edited: this didn't work
end applicationShouldHandleReopen_hasVisibleWindows_
as AppleScriptObjC apps have no run handler, use something like
on applicationWillFinishLaunching_(aNotification)
myRunHandler()
end applicationWillFinishLaunching_
on applicationShouldHandleReopen_hasVisibleWindows_(theApplication, aFlag)
myRunHandler()
return false -- as the app has no windows you can return false
end applicationShouldHandleReopen_hasVisibleWindows_
on myRunHandler()
-- do something
end myRunHandler
Can I call the applicationDidFinishLaunching method? Like this:
on applicationWillFinishLaunching_(aNotification)
-- initilize
end applicationWillFinishLaunching_
on applicationShouldHandleReopen_hasVisibleWindows_(theApplication, aFlag)
my applicationDidFinishLaunching_(aNotification) -- how to get aNotification?
return false -- as the app has no windows you can return false
end applicationShouldHandleReopen_hasVisibleWindows_
on applicationDidFinishLaunching_(aNotification)
-- do something
end applicationDidFinishLaunching_
I wanted to keep the main part of the script in the applicationDidFinishLaunching handler. I read in the Developer docs something about using that handler for the notification. But, if it can’t be done then, I can switch the main part of the script in my own handler.
Editted: forgot to change the handler name in the WillFinishLaunching.
Edited: no we don’t need that! Sorry, I’m starting to rush.