One… given an application name … say “XCODE.APP”
a) determine where it is located [in a FolderItem, NIL if it is not available]
b) determine if it is currently running [which of course would be false if not even installed ]
c) [Extra Credit] what files (if any) that application has open
d) [Extra Credit] be able to shut the app down [with user confirmation of course]
Declares or AppleScript would be acceptable
And (in the spirit of other recent topics)… You all know I have done my homework first
I can (kind of) knock off three of these. The problem is that if the application specified is not on the computer then a dialog will pop up to ask the user where the application is located. I will look into how to solve that tomorrow, but hopefully these will help for now.
a) Save the following Applescript code as a script (determineApplicationPath) and drag it into Xojo:
on run {theApp}
set thePath to (POSIX path of (path to application theApp))
return thePath as string
end run
Xojo code:
dim f as new FolderItem(determineApplicationPath("Xcode.app"))
// f is a folder item pointing to Xcode
b) AppleScript (saved as isRunning):
on run {appName}
if application appName is running then
set isRunning to true
else
set isRunning to false
end if
return isRunning as string
end run[/code]
Xojo code:
[code]dim running as Boolean = if(isRunning("Xcode") = "true", true, false)[/code]
d) AppleScript (quitApp):
[code]on run {appName}
--ignoring application responses
tell application appName
quit
end tell
--end ignoring
end run
You will need to uncomment the “ignoring application responses” and “end ignoring” if you want to hard quit the app and not allow the user to save.
Xojo code: