Hallo Leute,
Das ist sozusagen der 1. Versuch einer Sinnvollen UDF. Bitte teilt mir eure Meinungen und ERfahrungen mit, auch wenn Sie nicht so schön sind...
Danke an alle...
Hier die Func:
Spoiler anzeigen
;============================================================================================
;
; Function Name: _PIdGetWindow
; Description: Returns the Windowhandle(s) owned by the specified process (PId only !).
;
; Parameter(s): $iPid - the owner-PID.
;
; $iWndState - WindowState´s (default = active Windows) Option´s as shown
; by Helpfile for WinGetState()
;
; $iOption - Optional : return/search methods :
; 0 - returns Processname for the window declared at $iWndState.
; 1 - returns new PID for the Process.
; 2 - returns WindowTitle for matches in $iWndState(default).
; 3 - returns WindowHandle for matches in $iWndState.
; 4 - returns WindowState for specified PId.
; 5 - returns an Array with all Data can found for Processes and Windows.
;
;
; Return Value(s): On Success - returns an Array (see below for $iOption method 5).
; $array[0][0] - number of Processes
; $array[x][0] - Processname
; $array[x][1] - ProcessId (if Process already exists, a new PId is given by this function)
; $array[x][2] - WindowTitle
; $array[x][3] - Windowhandle
; $array[x][4] - Windowstate
;
; On Failure - returns 0 and sets @error to 1.
;
; Note´s: For this Function, <Array.au3> & <Process.au3> must be included.
;
; Author(s): Stinger2K
;
;============================================================================================
Func _PIdGetWindow($iPId, $iWndState = 2, $iOption = 2)
Local $aResult[1]
Local $var = _ProcessGetName($iPId)
Local $test = ProcessExists($var)
Local $handle_name = WinList()
If $test <> $iPId Then ; make sure that process exits once
ProcessClose($var)
Sleep(1000)
EndIf
ProcessWait($var)
For $i = 1 To $handle_name[0][0]
ReDim $aResult[UBound($aResult) + 1][5]
$aResult[UBound($aResult) - 1][0] = _ProcessGetName(WinGetProcess($handle_name[$i][1]))
$aResult[UBound($aResult) - 1][1] = WinGetProcess($handle_name[$i][1])
$aResult[UBound($aResult) - 1][2] = $handle_name[$i][0]
$aResult[UBound($aResult) - 1][3] = $handle_name[$i][1]
$aResult[UBound($aResult) - 1][4] = WinGetState($handle_name[$i][1])
If $aResult[$i][1] = $iPId And BitAND(WinGetState($aResult[$i][3]), $iWndState) Then
If $iOption = 0 Then
Return $aResult[$i][0] ; Processname
ElseIf $iOption = 1 Then
Return $aResult[$i][1] ; new PID
ElseIf $iOption = 2 Then
Return $aResult[$i][2] ; WindowTitle
ElseIf $iOption = 3 Then
Return $aResult[$i][3] ; Windowhandle
ElseIf $iOption = 4 Then
Return $aResult[$i][4] ; Windowstate
EndIf
Else
EndIf
Next
If $iOption = 5 Then
_ArraySort($aResult)
Return $aResult
EndIf
If $iOption > 5 Or $iOption < 0 Then
Return -2
EndIf
SetError(1)
Return -1
EndFunc ;==>_PIdGetWindow