Shocker Posted July 16, 2017 Share Posted July 16, 2017 Hi there... Need a handle and try to get it from PID. I use _WinGetByPID but i get a "wrong" handle from this Process (use Window Info to check). If i use it for notepad.exe, calc.exe or mspaint.exe i get the right one. What's going wrong? MsgBox(0, "", _WinGetByPID("calc.exe", 1)) Func _WinGetByPID($iPID, $iArray = 1) ; 0 Will Return 1 Base Array & 1 Will Return The First Window. Local $aError[1] = [0], $aWinList, $sReturn If IsString($iPID) Then $iPID = ProcessExists($iPID) EndIf $aWinList = WinList() For $A = 1 To $aWinList[0][0] If WinGetProcess($aWinList[$A][1]) = $iPID And BitAND(WinGetState($aWinList[$A][1]), 2) Then If $iArray Then Return $aWinList[$A][1] EndIf $sReturn &= $aWinList[$A][1] & Chr(1) EndIf Next If $sReturn Then Return StringSplit(StringTrimRight($sReturn, 1), Chr(1)) EndIf Return SetError(1, 0, $aError) EndFunc ;==>_WinGetByPID Link to comment Share on other sites More sharing options...
Shocker Posted July 16, 2017 Author Share Posted July 16, 2017 Think i found my mistake in Line 10. Have changed WinGetProcess($aWinList[$A][1]) into WinGetProcess($aWinList[$A][0]) and now script return correct handle. 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