Jump to content

how to set state with multiple windows


Hanyu
 Share

Recommended Posts

$WL = WinList("Window name")
If IsArray($WL)
    For $INDEX = 1 To $WL[0][0]
        WinSetState($WL[$INDEX][1],@SW_SHOW) ;Replace @SW_SHOW with any other state
    Next
EndIf

NO :D

WinSetState :

Remarks

If multiple windows match the criteria, the most recently active window is used.

multiple windows with one name ???

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
Opt("WinTitleMatchMode", 3) 
$GUI = GUICreate("List Windows", 205, 180, -1, -1, $WS_SYSMENU,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
GUICtrlCreateGroup("",5,5, 190, 45)
GUICtrlCreateLabel('List Windows', 120, 5, 70, 15)
$ComboWin = GUICtrlCreateCombo("", 10, 20, 180, 20)
$btnSetHide = GUICtrlCreateButton("Hide", 15, 132, 50, 20)
$btnSetShow = GUICtrlCreateButton('Show', 75, 132, 50, 20)
$btnRefesh = GUICtrlCreateButton('Refesh', 135, 132, 50, 20)
GUICtrlCreateGroup('', 5, 50, 190, 80)
GUICtrlCreateLabel('Window Selected', 100, 50, 90, 15)
$ListWinSelect = GUICtrlCreateList("", 10, 65, 180, 60)
_GetListWin()
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch($msg)
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ComboWin
            _GetWinSelected()
        Case $btnSetHide
            _Hide()
        Case $btnSetShow
            _Show()
        Case $btnRefesh
            _GetListWin()
        
    EndSwitch
WEnd

Func _GetListWin()
    $List = WinList()
For $i = 1 To $List[0][0]
    If $List[$i][0] <> "" And _Visible($List[$i][1]) Then
        $Hwn = WinGetHandle($List[$i][0], "")
        GUICtrlSetData($ComboWin, $List[$i][0] & "-"&$Hwn &"-"&$i)
    EndIf
Next
EndFunc
;--------------
Func _Visible($Win)
    If BitAnd(WinGetState($Win), 1) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
;------------------
Func _Hide()
    $TW = GUICtrlRead($ListWinSelect)
    If $TW = "" Then
        TrayTip('Warning', 'No Windows Selected !', 5,1)
    Else
        $Title = StringLeft($TW, StringInStr($TW, '-')-1)
        $HandleW = StringRight($TW,StringLen($TW) - StringInStr($TW, '-'))
        $trueHandle = WinGetHandle($Title)
            WinSetState($Title  , "", @SW_HIDE)
    EndIf
EndFunc
;--------------------
Func _Show()
    $TW = GUICtrlRead($ListWinSelect)
    If $TW = "" Then
        TrayTip('Thong Bao', 'Chua chon Windows', 5,1)
    Else
        $Title = StringLeft($TW, StringInStr($TW, '-')-1)
        $HandleW = StringRight($TW,StringLen($TW) - StringInStr($TW, '-'))
        $trueHandle = WinGetHandle($Title)
            WinSetState($Title, "", @SW_SHOW)
    EndIf
EndFunc
;--------------
Func _GetWinSelected()
    $T = GUICtrlRead($ComboWin)
    $TW = StringLeft($T, StringInStr($T, '-')-1)
    GUICtrlSetData($ListWinSelect, $T&"|")
EndFunc

:D

Can not set the status to the window with a name.

Can set the status by using the handle?

Edited by Hanyu
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...