Jump to content

Help with WinSetState


 Share

Recommended Posts

i'm trying to write a script to hide certain windows that selected from a list of visible windows

the problem is winsetstate isn't working

some code copied from help file

here is my code:

#include <GuiConstants.au3>
#Include <GuiList.au3>

GuiCreate("MyGUI", 392, 241,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Group_1 = GuiCtrlCreateGroup("Windows List", 10, 10, 370, 220)
$Button_1 = GuiCtrlCreateButton("Hide", 60, 180, 110, 40)
$Button_2 = GuiCtrlCreateButton("Show", 200, 180, 100, 40)
$List_2 = GUICtrlCreateList("", 20, 30, 350, 149, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetLimit(-1,200)
$WinList = WinList()
For $i = 1 to $WinList[0][0]
    If $WinList[$i][0] <> "" And IsVisible($WinList[$i][0]) Then
        GUICtrlSetData($List_2, $WinList[$i][0])
    EndIf
Next

GuiSetState()
While 1
    $msg = GuiGetMsg()
    
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        $select = _GUICtrlListGetSelItems($List_2)
        If (Not IsArray($select)) Then
            MsgBox(16, "Error", "No item selected")
        Else
            For $j = 1 To $select[0]
                WinSetState($select[$j], WinGetText($select[$j]), @SW_HIDE)
            ;_GUICtrlListSetSel($List_2, 0, 0)
            Next
        EndIf
    EndSelect
WEnd
Exit

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

hope some1 can help solve this problem, thanx guys

Link to comment
Share on other sites

Use _GUICtrlListGetSelItemsText() as Thatsgreat2345 suggested. ;)

#include <GuiConstants.au3>
#Include <GuiList.au3>

GuiCreate("MyGUI", 392, 241,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Group_1 = GuiCtrlCreateGroup("Windows List", 10, 10, 370, 220)
$Button_1 = GuiCtrlCreateButton("Hide", 60, 180, 110, 40)
$Button_2 = GuiCtrlCreateButton("Show", 200, 180, 100, 40)
$List_2 = GUICtrlCreateList("", 20, 30, 350, 149, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetLimit(-1,200)
$WinList = WinList()
For $i = 1 to $WinList[0][0]
    If $WinList[$i][0] <> "" And IsVisible($WinList[$i][0]) Then
        GUICtrlSetData($List_2, $WinList[$i][0])
    EndIf
Next

GuiSetState()
While 1
    $msg = GuiGetMsg()
    
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        $select = _GUICtrlListGetSelItemsText($List_2)
        If Not IsArray($select) Then
            MsgBox(16, "Error", "No item selected")
        Else
            For $j = 1 To $select[0]
                WinSetState($select[$j], '', @SW_HIDE)
            ;_GUICtrlListSetSel($List_2, 0, 0)
            Next
        EndIf
    EndSelect
WEnd
Exit

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then
    Return 1
  Else
    Return 0
  EndIf
EndFunc
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...