Jump to content

A little window hiding program


Recommended Posts

I made it today, and realized that it could be much better. I'd like to present it to you guys for your ideas as to what I can do to make improvements, additions to the code to add further functionality and efficiency and such.

Also, versus having the button for "all" windows, would there be a way to make it so that it only displayed invisible windows?

#include <GUIConstants.au3>

GUICreate("Windows Open", 641, 461)
dim $windows, $i, $mess, $selected, $testtext, $edit, $windowtohide, $windowtohide1, $hax
$list = GUICtrlCreateList("", 1, 1, 300, 400, $WS_VSCROLL)
$list2 = GUICtrlCreateList("", 340, 1, 300, 400, $WS_VSCROLL)
$button = GUICtrlCreateButton("Visible", 110, 401, 60, 20)
$button2 = GUICtrlCreateButton("All", 110, 421, 60, 20)
$addtolist2 = GUICtrlCreateButton(">>", 301, 180, 38, 20)
$clear = GUICtrlCreateButton("Clear", 470, 401, 60, 20)
$hide = GUICtrlCreateButton("Hide", 470, 421, 60, 20)
$show = GUICtrlCreateButton("Show", 470, 441, 60, 20)
$blah = 1
$stop = GUICtrlCreateButton("Stop", 300, 401, 40, 20)
GUISetState()
    While $mess <> $GUI_EVENT_CLOSE
        $mess = GUIGetMsg()
        If $mess = $button Then Call("populate")
        If $mess = $button2 Then Call("populateall")
        If $mess = $addtolist2 Then Call("addtolist")
        If $mess = $clear Then Call("clear")
        If $mess = $hide Then Call("hidethem")
        If $mess = $show Then Call("showthem")
        If $mess = $stop Then Sleep(100)
    WEnd
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    $hax = 2
EndIf
EndFunc
Func populate()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0] 
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then 
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func populateall()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0]
        If $windows[$i][0] <> "" Then 
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func addtolist()
    $selected = GUICtrlRead($list)
    GUICtrlSetData($list2, $selected)
    GUICtrlRead($blah)
    GUICtrlSetData($list2, $blah)
    $blah = $blah + 1
EndFunc
Func clear()
    GUICtrlSetData($list2, "")
    $blah = 1
EndFunc
Func hidethem()
    ControlFocus("Windows Open", "", $list2)
    ControlSend("Windows Open", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_HIDE) 
        ControlSend("Windows Open", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Windows Open", "", $list2, "{DOWN}")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc
Func showthem()
    ControlFocus("Windows Open", "", $list2)
    ControlSend("Windows Open", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_SHOW) 
        ControlSend("Windows Open", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Windows Open", "", $list2, "{DOWN}")
        WinSetState("Windows Open", "", @SW_ENABLE)
        WinActivate("Windows Open")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc
Link to comment
Share on other sites

Hi,

haven't test all. But 1 thing, don't use Call(),cause it is slower.

So long,

Mega

Change r.g Call("showthem") to showthem()

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

The way you use Call in your script is useless, and you can do it much easier without it.

Call can be used when you want to have a more dynamic setup in your script, calling

functions with the help of variables and such, for example like in this code below :

$number = Random(1, 3, 1)
Call("_Func" & $number)

Func _Func1()
    MsgBox(64, "", "Function 1")
EndFunc

Func _Func2()
    MsgBox(64, "", "Function 2")
EndFunc

Func _Func3()
    MsgBox(64, "", "Function 3")
EndFunc
Link to comment
Share on other sites

Thanks to luvmachine, I now have a show invisible function. (I was quite the noob in not being able to figure that part out myself)

;Window Hider
#include <GUIConstants.au3>
GUICreate("Window Hider", 641, 461)
dim $windows, $i, $mess, $selected, $testtext, $edit, $windowtohide, $windowtohide1, $hax
$list = GUICtrlCreateList("", 1, 1, 300, 400, $WS_VSCROLL)
$list2 = GUICtrlCreateList("", 340, 1, 300, 400, $WS_VSCROLL)
$button = GUICtrlCreateButton("Visible", 110, 401, 60, 20)
$button2 = GUICtrlCreateButton("Invisible", 110, 421, 60, 20)
$button3 = GUICtrlCreateButton("All", 110, 441, 60, 20)
$addtolist2 = GUICtrlCreateButton(">>", 301, 180, 38, 20)
$clear = GUICtrlCreateButton("Clear", 470, 401, 60, 20)
$hide = GUICtrlCreateButton("Hide", 470, 421, 60, 20)
$show = GUICtrlCreateButton("Show", 470, 441, 60, 20)
$blah = 1
$stop = GUICtrlCreateButton("Stop", 300, 401, 40, 20)
GUISetState()
    While $mess <> $GUI_EVENT_CLOSE
        $mess = GUIGetMsg()
        If $mess = $button Then populate()
        If $mess = $button2 Then populateinvis()
        If $mess = $button3 Then populateall()
        If $mess = $addtolist2 Then addtolist()
        If $mess = $clear Then clear()
        If $mess = $hide Then hidethem()
        If $mess = $show Then showthem()
        If $mess = $stop Then Sleep(100)
    WEnd
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
EndIf
EndFunc
Func populate()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0] 
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then 
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func populateinvis()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0]
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) = 0 Then
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func populateall()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0]
        If $windows[$i][0] <> "" Then
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func addtolist()
    $selected = GUICtrlRead($list)
    GUICtrlSetData($list2, $selected)
    GUICtrlRead($blah)
    GUICtrlSetData($list2, $blah)
    $blah = $blah + 1
EndFunc
Func clear()
    GUICtrlSetData($list2, "")
    $blah = 1
EndFunc
Func hidethem()
    ControlFocus("Window Hider", "", $list2)
    ControlSend("Window Hider", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_HIDE) 
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Window Hider", "", $list2, "{DOWN}")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc
Func showthem()
    ControlFocus("Window Hider", "", $list2)
    ControlSend("Window Hider", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_SHOW) 
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        WinSetState("Window Hider", "", @SW_ENABLE)
        WinActivate("Window Hider")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc
Link to comment
Share on other sites

An INI would be good. also, I just pretty much revamped my code... discovered the GuiList.au3 include :D

#include <GUIConstants.au3>
#include <GuiList.au3>
#include <Array.au3>

GUICreate("Window Hider", 641, 461)

Dim $windows, $i, $mess, $selected, $testtext, $edit, $windowtohide, $windowtohide1, $hax

$list = GUICtrlCreateList("", 1, 1, 300, 400, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
$list2 = GUICtrlCreateList("", 340, 1, 300, 400, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
$button = GUICtrlCreateButton("Visible", 110, 401, 60, 20)
$button2 = GUICtrlCreateButton("Invisible", 110, 421, 60, 20)
$button3 = GUICtrlCreateButton("All", 110, 441, 60, 20)
$addtolist2 = GUICtrlCreateButton(">>", 301, 180, 38, 20)
$clearsel = GUICtrlCreateButton("Clear Selected", 450, 385, 80, 20)
$clearall = GUICtrlCreateButton("Clear All", 450, 406, 80, 20)
$hidesel = GUICtrlCreateButton("Hide Selected", 340, 385, 80, 20)
$showsel = GUICtrlCreateButton("Show Selected", 559, 385, 80, 20)
$hideall = GUICtrlCreateButton("Hide All", 340, 406, 80, 20)
$showall = GUICtrlCreateButton("Show All", 559, 406, 80, 20)


GUISetState()
While $mess <> $GUI_EVENT_CLOSE
    $mess = GUIGetMsg()
    If $mess = $button Then populate()
    If $mess = $button2 Then populateinvis()
    If $mess = $button3 Then populateall()
    If $mess = $addtolist2 Then addtolist()
    If $mess = $clearsel Then clearsel()
    If $mess = $clearall Then clearall()
    If $mess = $hidesel Then hideselected()
    If $mess = $hideall Then hideall()
    If $mess = $showsel Then showselected()
    If $mess = $showall Then showall()
    WEnd
    
    
Func IsVisible($handle)
    If BitAND( WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible


Func populate()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 To $windows[0][0]
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then
            GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc   ;==>populate


Func populateinvis()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 To $windows[0][0]
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) = 0 Then
            GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc   ;==>populateinvis


Func populateall()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 To $windows[0][0]
        If $windows[$i][0] <> "" Then
            GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc   ;==>populateall


Func addtolist()
    $selected = _GUICtrlListGetSelItemsText($list)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            GUICtrlSetData($list2, $selected[$i])
        Next
    EndIf
EndFunc   ;==>addtolist


Func clearsel()
    $selected = _GUICtrlListGetSelItems($list2)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            _GUICtrlListDeleteItem($list2, $selected[$i])
        Next
    EndIf
    $blah = 1
EndFunc   ;==>clearsel


Func clearall()
    GUICtrlSetData($list2, "")
EndFunc   ;==>clearall


Func hideselected()
    $selected = _GUICtrlListGetSelItemsText($list2)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            $windowtohide = $selected[$i]
            WinSetState($windowtohide, "", @SW_HIDE)
        Next
    EndIf
EndFunc   ;==>hideselected


Func hideall()
    _GUICtrlListSelItemRange($list2, "", _GUICtrlListCount($list2) - _GUICtrlListCount($list2), _GUICtrlListCount($list2) - 1)
    $selected = _GUICtrlListGetSelItemsText($list2)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            $windowtohide = $selected[$i]
            WinSetState($windowtohide, "", @SW_HIDE)
        Next
    EndIf
EndFunc   ;==>hideall


Func showselected()
    $selected = _GUICtrlListGetSelItemsText($list2)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            $windowtohide = $selected[$i]
            WinSetState($windowtohide, "", @SW_SHOW)
        Next
    EndIf
EndFunc   ;==>showselected


Func showall()
    _GUICtrlListSelItemRange($list2, "", _GUICtrlListCount($list2) - _GUICtrlListCount($list2), _GUICtrlListCount($list2) - 1)
    $selected = _GUICtrlListGetSelItemsText($list2)
    If IsArray($selected) Then
        For $i = 1 To $selected[0]
            $windowtohide = $selected[$i]
            WinSetState($windowtohide, "", @SW_SHOW)
        Next
    EndIf
EndFunc   ;==>showall
Edited by Minion
Link to comment
Share on other sites

  • 2 weeks later...

OK I found this one somewhere around here dont remeber the exact thread though. It works great.

;Window Hider
#include <GUIConstants.au3>
GUICreate("Window Hider", 641, 461)
dim $windows, $i, $mess, $selected, $testtext, $edit, $windowtohide, $windowtohide1, $hax
$list = GUICtrlCreateList("", 1, 1, 300, 400, $WS_VSCROLL)
$list2 = GUICtrlCreateList("", 340, 1, 300, 400, $WS_VSCROLL)
$button = GUICtrlCreateButton("Visible", 110, 401, 60, 20)
$button2 = GUICtrlCreateButton("Invisible", 110, 421, 60, 20)
$button3 = GUICtrlCreateButton("All", 110, 441, 60, 20)
$addtolist2 = GUICtrlCreateButton(">>", 301, 180, 38, 20)
$clear = GUICtrlCreateButton("Clear", 470, 401, 60, 20)
$hide = GUICtrlCreateButton("Hide", 470, 421, 60, 20)
$show = GUICtrlCreateButton("Show", 470, 441, 60, 20)
$blah = 1
$stop = GUICtrlCreateButton("Stop", 300, 401, 40, 20)
GUISetState()
    While $mess <> $GUI_EVENT_CLOSE
        $mess = GUIGetMsg()
        If $mess = $button Then populate()
        If $mess = $button2 Then populateinvis()
        If $mess = $button3 Then populateall()
        If $mess = $addtolist2 Then addtolist()
        If $mess = $clear Then clear()
        If $mess = $hide Then hidethem()
        If $mess = $show Then showthem()
        If $mess = $stop Then Sleep(100)
    WEnd
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
EndIf
EndFunc
Func populate()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0] 
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then 
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func populateinvis()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0]
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) = 0 Then
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func populateall()
    GUICtrlSetData($list, "")
    $windows = WinList()
    For $i = 1 to $windows[0][0]
        If $windows[$i][0] <> "" Then
        GUICtrlSetData($list, $windows[$i][0])
        EndIf
    Next
EndFunc
Func addtolist()
    $selected = GUICtrlRead($list)
    GUICtrlSetData($list2, $selected)
    GUICtrlRead($blah)
    GUICtrlSetData($list2, $blah)
    $blah = $blah + 1
EndFunc
Func clear()
    GUICtrlSetData($list2, "")
    $blah = 1
EndFunc
Func hidethem()
    ControlFocus("Window Hider", "", $list2)
    ControlSend("Window Hider", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_HIDE) 
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Window Hider", "", $list2, "{DOWN}")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc
Func showthem()
    ControlFocus("Window Hider", "", $list2)
    ControlSend("Window Hider", "", $list2, "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
    Do  
        $windowtohide = GUICtrlRead($list2)
        WinSetState($windowtohide, "", @SW_SHOW) 
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        $windowtohide1 = GUICtrlRead($blah)
        ControlSend("Window Hider", "", $list2, "{DOWN}")
        WinSetState("Window Hider", "", @SW_ENABLE)
        WinActivate("Window Hider")
    Until  $windowtohide = $windowtohide1 Or $mess = $stop
EndFunc

Enjoy!

- Dan [Website]

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...