Jump to content

how to get win name from PID


E1M1
 Share

Recommended Posts

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

Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...