Rece Posted January 5, 2006 Share Posted January 5, 2006 I need to use Run() to execute apps. Run() gives me the PID of the process but I need the title of its main window. I've found only WinGetProcess() but I need "ProcessGetWin()".Is there any way to retrieve the window title of a process?There is a button in my script which starts an app. If the user clicks the button my script executes the app. If the user clicks the button again my program should not execute the app if it is already running but set its window to the top. But to do this I need something about the window title of the app... Link to comment Share on other sites More sharing options...
trids Posted January 6, 2006 Share Posted January 6, 2006 Sysinternals provides a variety of commandline toosl that you can automate nicely with an AU3 script. See if there is something here that might help you ..http://www.sysinternals.com/Utilities/PsTools.htmlHTH Link to comment Share on other sites More sharing options...
DarkNecromancer Posted January 6, 2006 Share Posted January 6, 2006 (edited) if i understand this correctly, that you want to go from PID to Title, then i belive this would work;this is your run command returning your PID $Process = Run ( "PROGRAMGOESHERE" ) sleep(3000) ;this gets the list of windows to sort through Dim $ProcList = WinList () ;browses through all of the items in the array returned For $i = 1 To $ProcList[0][0] If WinGetProcess ( $ProcList[$i][1] ) = $Process Then ;this here means the PID was found on the list, IE its running ; you would have your activate code here msgbox(0,"",$ProcList[$i][0]) EndIf Next ;here you would place the 'run again' command if its not running ;run ( "RUNME" )i couldn't get very specific because i don't know what your doing with this but hopefully you get the basic idea, the for and the winlist + getprocess is what you really need. Hope that helps ~Dark Edited January 6, 2006 by DarkNecromancer Link to comment Share on other sites More sharing options...
Rece Posted January 6, 2006 Author Share Posted January 6, 2006 Thanks! This is exactly what I need! This WinList() function is the solution. I didn't find that... If you click the button my script queries the WMI class Win32_Process and checks if the program is running or not. This WMI class gives me the PID too so I don't need to store it. (You can execute several apps from my script so there can be more than one PID...) Then WinActivate() and done... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now