Jump to content

Window Hider by FaT3oYCG


FaT3oYCG
 Share

Recommended Posts

I made a simple script that you can use to hide and show windows on your computer, I mainly made it for myself but thought that it mght be nice to share it with everyone. I don't really code in AutoIt much but I do sometimes use other languages.

So here is the code for the Window Hider application. I know there is a singleton thing or whatever it is, but using the method that I did for my script seemed simpler.

TraySetState(2)

If WinExists("Window Hider - V0.01 Created By FaT3oYCG - Running") Then
    MsgBox(0, "Warning!", 'Another instance of "Window Hider" has been detected' & @CRLF & @CRLF & "Exiting ...")
    Exit
EndIf

HotKeySet("^{space}", "Show_All")
HotKeySet("^d", "Hide_Active")
HotKeySet("^t", "Show_ToolTip")
HotKeySet("^e", "Quit")

$Main = GUICreate("Window Hider - V0.01 Created By FaT3oYCG - Running", 0, 0, @DesktopWidth, @DesktopHeight)

Dim $Hidden_Windows[100]
Dim $Hidden_Num = 1

While 1
    $Windows = WinList()
WEnd

Func Show_All()
    For $i = 1 to ($Hidden_Num - 1)
        If $Hidden_Windows[$i] <> "" Then
            WinSetState($Hidden_Windows[$i], "", @SW_SHOW)
        EndIf
    Next
    $Hidden_Num = 1
EndFunc

Func Hide_Active()
    If WinGetTitle("[ACTIVE]") <> "" Then
        $Hidden_Windows[$Hidden_Num] = WinGetTitle("[ACTIVE]")
        $Hidden_Num += 1
        WinSetState("[ACTIVE]", "", @SW_HIDE)
    EndIf
EndFunc

Func Show_ToolTip()
    ToolTip("Press:" & @CRLF & "Ctrl & t to show this Tool Tip" & @CRLF & "Ctrl & d to hide the active (selected) window" & @CRLF & "Ctrl & Space Bar to show all hidden windows"& @CRLF & 'Ctrl & e to exit "Window Hider"')
    Sleep(2000)
    ToolTip("")
EndFunc

Func Quit()
    MsgBox(0, "Closing!", '"Window Hider" has been closed')
    WinKill("Window Hider - V0.01 Created By FaT3oYCG - Running")
    Exit
EndFunc
Edited by FaT3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Link to comment
Share on other sites

Pretty cool. I made on pretty similar.

Uses Trayicon. Click Tray icon to hide/restore windows. Ctrl+Shift+Alt+H hides active win or Hides/Displays Tray Icon if no window is active.

#NoTrayIcon
#Include <GuiComboBox.au3>
#include <Array.au3>

Dim $trayshow = 1
Dim $hiddenwins[1]

Opt("TrayMenuMode",1)
TraySetIcon("Shell32.dll",-95)
TraySetToolTip("HideInTray")

$hide = TrayCreateItem("&Hide")
$trayexit = TrayCreateItem("Exit")
TrayCreateItem("")

HotKeySet("!^+h","_HideThisWin")  ;Ctrl+Shift+Alt+H

While 1
    $msg = TrayGetMsg()
    If $msg = $hide Then _HideWin()
    If $msg = $trayexit Then _Exit()
    For $i = 0 to UBound($hiddenwins)-1
        If $i <= UBound($hiddenwins)-1 Then 
            If $msg = $hiddenwins[$i] Then _UnHideWin($i)
        EndIf
    Next
WEnd

Func _HideThisWin()
    $winlist = WinList()
    For $i = 1 to $winlist[0][0]
        If IsVisible($winlist[$i][0]) And WinActive($winlist[$i][0]) And $winlist[$i][0] <> "Program Manager" And $winlist[$i][0] <> "" Then 
            _HideWin($winlist[$i][0] & "(" & $winlist[$i][1] & ")")
            Return 0
        EndIf
    Next
    If $trayshow Then
        $trayshow = 0
        TraySetState(2)
    Else
        $trayshow = 1
        TraySetState(1)
    EndIf
EndFunc

Func _Exit()
    Do
        _UnHideWin(0)
    Until $hiddenwins[0] = ""
    Exit
EndFunc

Func _UnHideWin($i)
    $hwnd = TrayItemGetText($hiddenwins[$i])
    If Not $hwnd Then Return 0
    $hwnd = StringLeft($hwnd,StringInstr($hwnd,"(0")-1)
    $hwnd = WinGetHandle($hwnd)
    If Not StringInstr(WinGetTitle($hwnd),"AutoIt") Then WinSetState($hwnd,"",@SW_SHOW)
    TrayItemDelete($hiddenwins[$i])
    _ArrayDelete($hiddenwins,$i)
    If Not IsArray($hiddenwins) Then Dim $hiddenwins[1]
EndFunc

Func _HideWin($hwnd = 0)
    If Not $hwnd Then
        $hwnd = _PickWin()
        If Not $hwnd Then Return 0
    EndIf
    If Not $hiddenwins[0] Then
        $hiddenwins[0] = TrayCreateItem($hwnd)
    Else
        ReDim $hiddenwins[UBound($hiddenwins)+1]
        $hiddenwins[UBound($hiddenwins)-1] = TrayCreateItem($hwnd)
    EndIf
    $hwnd = StringLeft($hwnd,StringInstr($hwnd,"(0")-1)
    $hwnd = WinGetHandle($hwnd)
    WinSetState($hwnd,"",@SW_HIDE)
EndFunc

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

Func _PickWin()
    $winX = @DesktopWidth * .4
    $winY = @DesktopHeight * .325
    $pickgui = GUICreate("Pick Window to Hide",$winX * .55,$winY * .35,-1,-1)
    $wins = GUICtrlCreateCombo("",(($winX * .55)-($winX * .5))/2,(($winY * .5)-($winY * .35))/2,$winX * .5,$winY * .35)
    
    $winlist = WinList()
    For $i = 1 to $winlist[0][0]
        If IsVisible($winlist[$i][0]) And $winlist[$i][0] <> "Program Manager" And $winlist[$i][0] Then _GUICtrlComboBox_AddString($wins,$winlist[$i][0] & "(" & $winlist[$i][1] & ")")
    Next
    
    GUISetState()
    WinSetOnTop($pickgui,"",1)
    
    WinActivate("Pick Window")
    WinWaitActive("Pick Window")
    
    While 1
        $msg = GuiGetMsg()
        If $msg = -3 Then ExitLoop
    WEnd
    
    $hwnd = GuiCtrlRead($wins)
    GuiDelete($pickgui)
    If $hwnd Then Return $hwnd
    Return 0
EndFunc
Edited by spudw2k
Link to comment
Share on other sites

nice, i would add a gui to mine or some more options but i really only created it for myself and it does what i need it to, as i am going to use it in college so that i can hide windows i dont want my teach to see, im not too bothered about it restoring them all because that just helps me, i will probably only use it to hide one window at a time anyway.

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

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