Is there a way (on Windows) to check if an external exe is running? I’ve used FindWindow API in .Net but not sure how to use it in Xojo.
Dim hwnd As IntPtr = FindWindow(Nothing, “Notepad”)
If hwnd = IntPtr.Zero Then
Here’s what I use. Pass in the name of the application and get a Boolean back.
Var tempString as String
Var tempShell as New Shell
tempShell.TimeOut = 30000
tempString = "tasklist /FI ""IMAGENAME eq " + appName + ""
Return tempShell.Result.IndexOf (appName) > -1
It worked great, thanks Dale!
what is the equivalent for mac??
var z as new Shell
var x as Integer
var a as String=“Safari”
if x=0 then
MessageBox(a+" is running")
MessageBox(a+" is not running")
just try this mbut using safari instead Safari and go no result. once change to Safari, got the following bunch of numbers?? what does it mean?? also don’t see the “is running” or “is not running”
when you type pgrep app-name in terminal - you will get list of processes for Safari… When you use z.Execute(“pgrep Safari”) then in z.ExitCode you will get zero or one (when no Safari process found)
so those number of line of process is how many tabs i have open ??
Public Function getPID(theApplication as String) as String
'Return PID via shell
if theApplication = "" then Return ""
dim theShell as new Shell
theShell.Execute "ps -alxwc"
if theShell.ExitCode <> 0 then Return ""
dim theResult as String = theShell.Result
dim NoOfLines as Integer = theResult.CountFields(EndOfLine.UNIX)
for currentLine as Integer = 1 to NoOfLines
dim theLine as String = theResult.NthField(EndOfLine.UNIX, currentLine)
if theLine.IndexOf(theApplication) > -1 then
Return mid(theLine, 7, 5)