Jump to content
Sign in to follow this  

How to retrieve the window title of a specified process?

Recommended Posts


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... :P

Share this post

Link to post
Share on other sites

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" )
;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
;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


Edited by DarkNecromancer

Share this post

Link to post
Share on other sites

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...

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.