Making an App Come to the Foreground |
|
The Macintosh portion of this code is implemented in AppleScript, and the Windows portion is implemented using
the PrcView* command line utility, and assumes that you have put the pv.exe application in
the same directory as your standalone (i.e. the default "directory").
function Activate pProcessName
switch (the platform)
case "MacOS"
put "tell application" && q("Finder") && cr & \
"set the frontmost of application process" && q(pProcessName) && "to true" & cr & \
"return (the result)" & cr & \
"end tell" into tScript
do tScript as AppleScript
if the result is "execution error" then return "Process not found."
break
case "Win32"
set the hideConsoleWindows to true
put shell("pv -q") into tProcList
if matchText(cr&tProcList&cr,"\n" & pProcessName & tab) is false then
return "Process not found."
else
get shell("pv -a " & pProcessName)
end if
break
end switch
end Activate
function q what
return quote & what & quote
end q
* PrcView is a command line utility developed by Igor Nys, and can be downloaded at
http://www.prcview.com/. PrcView is free for personal use or to be
distributed with freeware applications; for shareware or commercial use, please contact Igor.
Licensing costs are very reasonable, and he is very willing to work with you to make it worth your while to use his application.
Posted 12/26/02 by Ken Ray