Jump to content

Window Manager


crzftx
 Share

Recommended Posts

It controls the visibility of all windows open on one's computer. It can also kill a window and change its name, very easily. It's pretty simple to get, I think. It minimizes to the tray, so as not to get in the way, and double-right click brings it back up.

#include <GUIConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>

Global $z,$temp,$List,$Amount = 0,$State,$Current

Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)
TraySetClick(1)
$Exit = TrayCreateItem("Exit")

$gui = GUICreate("WinN",600,400,-1,-1,0x80CA0000)
$ListAll = GUICtrlCreateListView("Title|State|Handle",20,20,410,200,0x1C)
_GUICtrlListViewSetColumnWidth($ListAll,0,260)
$ListEx = GUICtrlCreateListView("Title|Handle",20,240,410,100,0x1C)
_GUICtrlListViewSetColumnWidth($ListEx,0,315)
$Title = GUICtrlCreateInput("",20,360,410,20)
$Lock = GUICtrlCreateCheckbox("Lock",450,360,130,20)
GUISetFont(12)
$Show_H = GUICtrlCreateCheckbox("",450,35,15,15)
    GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlCreateLabel("Show Hidden Windows",470,25,110,40)
$Show_N = GUICtrlCreateCheckbox("",450,90,15,15)
    GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlCreateLabel("Show Windows With No Title",470,80,110,40)
$Refresh = GUICtrlCreateButton("Refresh",450,135,130,30)
$Add = GUICtrlCreateButton("Add",450,180,130,30)
$Hidden = GUICtrlCreateCheckbox("Hidden",450,244,130,20)
$Kill = GUICtrlCreateButton("Kill",450,272,130,30)
$Remove = GUICtrlCreateButton("Remove",450,310,130,30)
GUISetFont(10)
GUISetState()

While 1
    If TrayGetMsg() = $Exit Then Exit
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $GUI_EVENT_MINIMIZE
            WinSetState($gui,"",@SW_HIDE)
            While 1
                Switch TrayGetMsg()
                    Case $Exit
                        Exit
                    Case $TRAY_EVENT_SECONDARYDOUBLE
                        ExitLoop
                EndSwitch
            WEnd
            WinSetState($gui,"",@SW_SHOW)
            WinActivate($gui)
        Case $Add
            $temp = GUICtrlRead(GUICtrlRead($ListAll),1)
            GUICtrlCreateListViewItem(StringLeft($temp,StringInStr($temp,"|"))&StringRight($temp,10),$ListEx)
        Case $Remove
            $temp = GUICtrlRead($ListEx)
            GUICtrlDelete($temp)
            GUICtrlSetState($temp-1,$GUI_FOCUS)
        Case $Show_H
            Refresh()
        Case $Show_N
            Refresh()
        Case $Refresh
            Refresh()
        Case $Hidden
            If BitAND(WinGetState($Current,""),2) Then
                WinSetState($Current,"",@SW_HIDE)
            Else
                WinSetState($Current,"",@SW_SHOW)
                WinActivate($gui,"")
            EndIf
            Refresh()
        Case $Kill
            $temp = GUICtrlRead($ListEx)
            WinKill($Current)
            If WinWaitClose($Current,"",2500) = 0 Then ProcessClose(WinGetProcess($Current))
            GUICtrlDelete($temp)
            GUICtrlSetState($temp-1,$GUI_FOCUS)
        Case $Lock
            MsgBox(0,"Sorry!","That doesn't work yet.")
    EndSwitch
    
    $List = WinList()
    If $List[0][0] <> $Amount Then
        Refresh()
    EndIf
    
    $temp = GUICtrlRead($ListEx)
    If $temp = 0 And $State <> 1 Then
        GUICtrlSetState($Hidden,$GUI_DISABLE)
        GUICtrlSetState($Hidden,$GUI_UNCHECKED)
        GUICtrlSetState($Kill,$GUI_DISABLE)
        GUICtrlSetState($Remove,$GUI_DISABLE)
        GUICtrlSetState($Title,$GUI_DISABLE)
        GUICtrlSetData($Title,"")
        GUICtrlSetState($Lock,$GUI_DISABLE)
        GUICtrlSetState($Lock,$GUI_UNCHECKED)
        $State = 1
    EndIf
    If $temp <> 0 Then
        $temp = GUICtrlRead($temp,1)
        If $State = 1 Then
            GUICtrlSetState($Hidden,$GUI_ENABLE)
            GUICtrlSetState($Title,$GUI_ENABLE)
            GUICtrlSetState($Kill,$GUI_ENABLE)
            GUICtrlSetState($Remove,$GUI_ENABLE)
            GUICtrlSetState($Lock,$GUI_ENABLE)
            GUICtrlSetData($Title,StringTrimRight($temp,11))
        EndIf
        If HWnd(StringRight($temp,10)) <> $Current Then GUICtrlSetData($Title,StringTrimRight($temp,11))
        $Current = HWnd(StringRight($temp,10))
        If GUICtrlRead($Title) <> StringTrimRight($temp,11) Then
            WinSetTitle($Current,"",GUICtrlRead($Title))
            If Not StringInStr(GUICtrlRead($Title),"|") Then GUICtrlSetData(GUICtrlRead($ListEx),GUICtrlRead($Title))
        EndIf
        If $Current = $gui And $State <> 4 Then
            GUICtrlSetState($Hidden,$GUI_DISABLE)
            GUICtrlSetState($Hidden,$GUI_UNCHECKED)
            GUICtrlSetState($Kill,$GUI_DISABLE)
            $State = 4
        EndIf
        If $Current <> $gui Then
            If $State = 4 Then
                GUICtrlSetState($Hidden,$GUI_ENABLE)
                GUICtrlSetState($Kill,$GUI_ENABLE)
            EndIf
            If BitAND(WinGetState($Current),2) And $State <> 2 Then
                GUICtrlSetState($Hidden,$GUI_UNCHECKED)
                $State = 2
            EndIf
            If BitAND(WinGetState($Current),2) = 0 And $State <> 3 Then
                GUICtrlSetState($Hidden,$GUI_CHECKED)
                $State = 3
            EndIf
        EndIf
    EndIf
WEnd

Func Refresh()
    _GUICtrlListViewDeleteAllItems($ListAll)
    For $z = 1 To $List[0][0]
        If BitAND(WinGetState($List[$z][1]),2) Then
            $temp = "Visible"
        Else
            $temp = "Hidden"
        EndIf
        If Not ((GUICtrlRead($Show_H) = $GUI_UNCHECKED And $temp = "Hidden") Or (GUICtrlRead($Show_N) = $GUI_UNCHECKED And $List[$z][0] = "")) Then _
        GUICtrlCreateListViewItem($List[$z][0]&"|"&$temp&"|"&$List[$z][1],$ListAll)
    Next
    $Amount = $List[0][0]
EndFunc
Edited by crzftx
Link to comment
Share on other sites

Kinda useful.

The clicking on the tray is a bit weird, why not just a regular click to hide/show?

It would be cool, too, if double-clikcing a window entry added it to the lower pane, for editing (the lower pane could do with a title, too, so you know what it's for - not that it takes a lot of figuring out, but still).

Changing their name doesn't actually do anything. Is it supposed to? I found the whole lower pane a bit strange, the editing behaviour, though I know myself that getting these things to behave can be tricky sometimes in AutoIt.

It's handy, though, I'll keep it around!

;o)

(or

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

well somebody else please give feedback on this, does changing the name work for you guys? it seems to for me. I will look into the double-click to add. I think double click to toggle shown/hidden could be useful. The lower pane's purpose is to help keep track of the windows that you have hidden, without searching through the list. (To change the name, type a new one in the bottom bar (when the window is selected in the lower pane). Sounds a bit confusing, actually very simple. I'll work on the double click though.

haven't tried it yet, I will when i get home, but if you want ideas or anything, you can look at my window manager: http://www.autoitscript.com/forum/index.php?showtopic=46819
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Hmm seems like you have a good start. Heres mine in case your interested. It basically has it's own scripting language built in so you can make it do things based on a set of conditions. I thought it was cool at least xD

Window Manager 2.0.au3 is the script you need to run. All the other scripts are just includes.

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