Jump to content
Sign in to follow this  
E1M1

how to get win name from PID

Recommended Posts

E1M1

I know that pid is X now how I get it's window name? for example notepad's pid is 1000 but it don't know it's window title, now how I get window title if i know only that pid is 1000?


edited

Share this post


Link to post
Share on other sites
Mat

Use WinList and then WinGetProcess in a loop!

GUICreate ("A success!!")

$ret = _ProcessGetWindow (@AutoitPID)

MsgBox (0, "The test was...", $ret)

Func _ProcessGetWindow ($nPid)
   Local $aList = WinList ()

   For $i = 1 to $aList[0][0]
      If winGetProcess ($aList[$i][1]) = $nPid Then Return $aList[$i][0]
   Next
   Return SetError (1, 0, "")
EndFunc ; ==> _ProcessGetWindow

Here we know that the GUI's PID will be autoit, so we test for that.

Mat

Share this post


Link to post
Share on other sites
Yashied

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.