Deye Posted March 20, 2017 Posted March 20, 2017 (edited) Hi, This is a small example for z ordering the available windows , 2 or more windows on top and other then explorer ones should create an array the problem is that a value wont be processed outside the main array either ways does anyone see or knows whats the problem here ? Thanks expandcollapse popup#AutoIt3Wrapper_Outfile=test.Exe #AutoIt3Wrapper_Run_After="%out%" #AutoIt3Wrapper_Run_Tidy=y #include <Array.au3> Local $aWinList = WinList("[REGEXPCLASS:^(Explore|Cabinet)WClass$]"), $next, $ztop ReDim $aWinList[UBound($aWinList)][$aWinList[0][1] + 3] For $i = UBound($aWinList) - 1 To 1 Step -1 $next = _WinGetNextWindow($aWinList[$i][1], "", 3) If $next > "" Then If $aWinList[$i - 1][1] = $next Then ContinueLoop $aWinList[$i][2] = $next Do $next = _WinGetNextWindow($next, "", 3) If $aWinList[$i - 1][1] = $next Then ExitLoop $aWinList[$i][2] &= ',' & $next Until $next = "" $aWinList[$i][2] = StringSplit($aWinList[$i][2], ',') EndIf Next _ArrayDisplay($aWinList) For $i = UBound($aWinList) - 1 To 1 Step -1 WinActivate($aWinList[$i][1]) If $aWinList[$i][2] <> "" Then ;~ $ztop = StringSplit($aWinList[$i][2], ',') If Not IsArray($aWinList[$i][2]) Then MsgBox(0, 'value is processed', WinGetTitle($aWinList[$i][2])) If WinExists($aWinList[$i][2]) Then WinActivate($aWinList[$i][2]) ;another test ;------------------------------------------------------------------------------- $ztop = StringSplit($aWinList[$i][2], ',') _ArrayDisplay($ztop, 'value from StringSplit') If IsArray($ztop) Then MsgBox(0, 'value not processed', WinGetTitle($ztop[1])) For $z = 1 To UBound($ztop) - 1 MsgBox(0, 'nothing', WinGetTitle($ztop[$z], '')) Next EndIf ;------------------------------------------------------------------------------- ElseIf IsArray($aWinList[$i][2]) Then $ztop = $aWinList[$i][2] _ArrayDisplay($ztop, '$ztop') For $z = 1 To UBound($ztop) - 1 MsgBox(0, 'nothing', WinGetTitle($ztop[$z], '')) Next EndIf EndIf Next Func _WinGetNextWindow($vWindow, $sText = "", $iCmd = 2) Local $hWnd = $vWindow, $aGetWindow If Not IsHWnd($vWindow) Then $hWnd = WinGetHandle($vWindow, $sText) If $hWnd = 0 Then Return "" If Not IsDeclared("GW_HWNDNEXT") Then Local Const $GW_HWNDNEXT = 2 If Not IsDeclared("GW_HWNDPREV") Then Local Const $GW_HWNDPREV = 3 If $iCmd <> $GW_HWNDNEXT And $iCmd <> $GW_HWNDPREV Then Return "" While 1 $aGetWindow = DllCall("User32.dll", "hwnd", "GetWindow", "hwnd", $hWnd, "uint", $iCmd) If @error Then Return "" If $aGetWindow[0] = 0 Then ExitLoop $hWnd = $aGetWindow[0] $aGetWindowLong = DllCall("User32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", -16) If @error Then ExitLoop If Not BitAND(WinGetState($hWnd), 2) Or $aGetWindowLong[0] < 0 Then ContinueLoop Return $hWnd WEnd Return "" EndFunc ;==>_WinGetNextWindow Edited March 20, 2017 by Deye
Deye Posted March 20, 2017 Author Posted March 20, 2017 NM .. got it fixed now was only missing an HWnd ( expression ) expandcollapse popup#AutoIt3Wrapper_Outfile=test.Exe #AutoIt3Wrapper_Run_After="%out%" #AutoIt3Wrapper_Run_Tidy=y #include <Array.au3> Local $aWinList = WinList("[REGEXPCLASS:^(Explore|Cabinet)WClass$]"), $next, $ztop ReDim $aWinList[UBound($aWinList)][$aWinList[0][1] + 3] For $i = UBound($aWinList) - 1 To 1 Step -1 $next = _WinGetNextWindow($aWinList[$i][1], "", 3) If $next > "" Then If $aWinList[$i - 1][1] = $next Then ContinueLoop $aWinList[$i][2] = $next Do $next = _WinGetNextWindow($next, "", 3) If $aWinList[$i - 1][1] = $next Then ExitLoop $aWinList[$i][2] &= ',' & $next Until $next = "" $aWinList[$i][2] = StringSplit($aWinList[$i][2], ',') EndIf Next ;~ _ArrayDisplay($aWinList) For $i = UBound($aWinList) - 1 To 1 Step -1 WinActivate($aWinList[$i][1]) If $aWinList[$i][2] <> "" Then If Not IsArray($aWinList[$i][2]) Then If WinExists($aWinList[$i][2]) Then WinActivate($aWinList[$i][2]) ElseIf IsArray($aWinList[$i][2]) Then $ztop = $aWinList[$i][2] For $z = 1 To UBound($ztop) - 1 If WinExists(HWnd($ztop[$z])) Then WinActivate(HWnd($ztop[$z])) Next EndIf EndIf Next Func _WinGetNextWindow($vWindow, $sText = "", $iCmd = 2) Local $hWnd = $vWindow, $aGetWindow If Not IsHWnd($vWindow) Then $hWnd = WinGetHandle($vWindow, $sText) If $hWnd = 0 Then Return "" If Not IsDeclared("GW_HWNDNEXT") Then Local Const $GW_HWNDNEXT = 2 If Not IsDeclared("GW_HWNDPREV") Then Local Const $GW_HWNDPREV = 3 If $iCmd <> $GW_HWNDNEXT And $iCmd <> $GW_HWNDPREV Then Return "" While 1 $aGetWindow = DllCall("User32.dll", "hwnd", "GetWindow", "hwnd", $hWnd, "uint", $iCmd) If @error Then Return "" If $aGetWindow[0] = 0 Then ExitLoop $hWnd = $aGetWindow[0] $aGetWindowLong = DllCall("User32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", -16) If @error Then ExitLoop If Not BitAND(WinGetState($hWnd), 2) Or $aGetWindowLong[0] < 0 Then ContinueLoop Return $hWnd WEnd Return "" EndFunc ;==>_WinGetNextWindow
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