Sign in to follow this  
Followers 0
Hanyu

how to set state with multiple windows

5 posts in this topic

hi, my question :

How do I set the status of multiple windows of the same name?

thank !

Share this post


Link to post
Share on other sites



$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


When the words fail... music speaks

Share this post


Link to post
Share on other sites

$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 ???

Share this post


Link to post
Share on other sites

Look what the code actually does. It do fixes the problem!


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#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

Share this post


Link to post
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
Sign in to follow this  
Followers 0