Sign in to follow this  
Followers 0
exodius

Script to Reorder Taskbar...

2 posts in this topic

I threw together the following script to allow me to reorder the windows on my taskbar... the problem is on some computers it adds windows that aren't really there despite the visible check. Any ideas on how to elminate the extras?

#include <GUIConstants.au3>
GUICreate("Window ReOrder", 620, 333, 192, 125)
$ListView1 = GUICtrlCreateListView("Window # | Window Name", 16, 8, 490, 310)
$MoveUp = GUICtrlCreateButton("Move Up", 520, 32, 91, 33)
$MoveDown = GUICtrlCreateButton("Move Down", 520, 80, 91, 33)
$MakeChanges = GUICtrlCreateButton("Make Changes", 520, 128, 91, 33)

$var = WinList()
Dim $list
Dim $Count = 1

For $i = 1 to $var[0][0]
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) And $var[$i][0] <> "Program Manager" Then
    GUICtrlCreateListViewItem ( $count & "|" & $var[$i][0], $ListView1)
    $count = $count + 1
  EndIf
Next

GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $MoveUp
        If GUICtrlRead ($ListView1) > 7 And GUICtrlRead ($ListView1) < $count + 7 - 1 Then
            If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1)), "|" ) Then
                If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1) - 1), "|" ) Then
                    $Selection = GuiCtrlRead ( $ListView1 )
                    $SelectionData = GUICtrlRead(GUICtrlRead($ListView1))
                    $SelectionDataSplit = StringSplit($SelectionData, "|" )
                    $SelectionDataWinNum = $SelectionDataSplit[1] - 1
                    $SelectionDataName = $SelectionDataSplit[2]
                    $SelectionData = $SelectionDataWinNum & "|" & $SelectionDataName
                    
                    $ToMove = GuiCtrlRead ( $ListView1 ) - 1
                    $ToMoveData = GUICtrlRead(GUICtrlRead($ListView1)- 1)
                    $ToMoveDataSplit = StringSplit($ToMoveData, "|" )
                    $ToMoveDataWinNum = $ToMoveDataSplit[1] + 1
                    $ToMoveDataName = $ToMoveDataSplit[2]
                    $ToMoveData = $ToMoveDataWinNum & "|" & $ToMoveDataName
                    
                    GuiCtrlSetData ( $ToMove, $SelectionData )
                    GUICtrlSetData ( $Selection, $ToMoveData )
                    ControlSend ( "Window ReOrder", "", $ListView1, "{Up}" )
                EndIf
            EndIf
        EndIf
        
    Case $msg = $MoveDown
        If GUICtrlRead ($ListView1) >= 7 And GUICtrlRead ($ListView1) <= $count + 7 - 1 Then
            If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1)), "|" ) Then
                If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1) + 1), "|" ) Then
                    $Selection = GuiCtrlRead ( $ListView1 )
                    $SelectionData = GUICtrlRead(GUICtrlRead($ListView1))
                    $SelectionDataSplit = StringSplit($SelectionData, "|" )
                    $SelectionDataWinNum = $SelectionDataSplit[1] + 1
                    $SelectionDataName = $SelectionDataSplit[2]
                    $SelectionData = $SelectionDataWinNum & "|" & $SelectionDataName
                    
                    $ToMove = GuiCtrlRead ( $ListView1 ) + 1
                    $ToMoveData = GUICtrlRead(GUICtrlRead($ListView1)+ 1)
                    $ToMoveDataSplit = StringSplit($ToMoveData, "|" )
                    $ToMoveDataWinNum = $ToMoveDataSplit[1] - 1
                    $ToMoveDataName = $ToMoveDataSplit[2]
                    $ToMoveData = $ToMoveDataWinNum & "|" & $ToMoveDataName
                    
                    GuiCtrlSetData ( $ToMove, $SelectionData )
                    GUICtrlSetData ( $Selection, $ToMoveData )
                
                    ControlSend ( "Window ReOrder", "", $ListView1, "{Down}" )
                EndIf
            EndIf
        EndIf
        
    Case $msg = $MakeChanges
        For $x = 1 To $count + 10
            If StringInStr ( GUICtrlRead($x), "|" ) Then
                $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" )
                WinSetState ( $MakeChangesSplit[2], "", @SW_HIDE )
            EndIf
        Next
        For $x = 7 To $count + 10
            If StringInStr ( GUICtrlRead($x), "|" ) Then
                $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" )
                WinSetState ( $MakeChangesSplit[2], "", @SW_SHOW )
            EndIf
        Next
    EndSelect
WEnd

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

Share this post


Link to post
Share on other sites



Bump de bump bump

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