Sign in to follow this  
Followers 0
exodius

Listing of Windows on Taskbar

2 posts in this topic

Is there a way to get a listing of the windows on the taskbar in the order that they appear there from left to right?

Share this post


Link to post
Share on other sites



In WinXP the taskbar is a ToolbarWindow32. I can send a message to that control to receive it's button names... but... the taskbar groups windows... To get a list of windows you may want to use WinList() and check for "visible" windows. There are caveats of course like WS_EX_TOOLWINDOWs and other "top level" windows that have no task bar reference... So what do you really specifically want?

Lar.

I'd like this script to be able to list the windows as they appear on the taskbar so if you just want to move one window the right one spot you don't have to completely redo the order.

#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

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