Jump to content
Sign in to follow this  
GaryFrost

Fun with the taskbar

Recommended Posts

In my search for information on the pager control (apparently not widely used except in windows itself) I ran across some old vb code.

I converted it to autoit and got it working on my XP machines (only tested on XP)

#include <WinAPI.au3>
;~ #include <WindowsConstants.au3>

Global Const $SW_HIDE                           = 0
Global Const $SW_SHOW                           = 5

_ShowTaskBar(False)
Sleep ( 2000 )
_ShowTaskBar()

_ShowStartButton(False)
Sleep ( 2000 )
_ShowStartButton()

_ShowTaskBarClock(False)
Sleep ( 2000 )
_ShowTaskBarClock()

_ShowTaskBarIcons(False)
Sleep ( 2000 )
_ShowTaskBarIcons()

For $x = 1 To _TaskBarIndexCount()
    _ShowProgramsShowingInTaskBar(False, $x)
    Sleep(2000)
    _ShowProgramsShowingInTaskBar(True, $x)
Next

Func _ShowTaskBar($fShow = True)
    Local $hTaskBar
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    If $fShow Then
        _WinAPI_ShowWindow($hTaskBar, $SW_SHOW)
    Else
        _WinAPI_ShowWindow($hTaskBar, $SW_HIDE)
    EndIf
EndFunc   ;==>_ShowTaskBar

Func _ShowStartButton($fShow = True)
    Local $hTaskBar, $hStartButton
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    $hStartButton = ControlGetHandle($hTaskBar, "", "Button1")
    If $fShow Then
        _WinAPI_ShowWindow($hStartButton, $SW_SHOW)
    Else
        _WinAPI_ShowWindow($hStartButton, $SW_HIDE)
    EndIf
EndFunc   ;==>_ShowStartButton

Func _ShowTaskBarClock($fShow = True)
    Local $hTaskBar, $hParent, $hClock
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    $hParent = ControlGetHandle($hTaskBar, "", "TrayNotifyWnd1")
    $hClock = ControlGetHandle($hParent, "", "TrayClockWClass1")
    If $fShow Then
        _WinAPI_ShowWindow($hClock, $SW_SHOW)
    Else
        _WinAPI_ShowWindow($hClock, $SW_HIDE)
    EndIf
EndFunc   ;==>_ShowTaskBarClock

Func _ShowTaskBarIcons($fShow = True)
    Local $hTaskBar, $hParent, $hChild
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    $hParent = ControlGetHandle($hTaskBar, "", "TrayNotifyWnd1")
    $hChild = ControlGetHandle($hParent, "", "ToolbarWindow321")
    If $fShow Then
        _WinAPI_ShowWindow($hChild, $SW_SHOW)
    Else
        _WinAPI_ShowWindow($hChild, $SW_HIDE)
    EndIf
EndFunc   ;==>_ShowTaskBarIcons

Func _ShowProgramsShowingInTaskBar($fShow = True, $iIndex = 1)
    Local $hTaskBar, $hRebar, $hToolBar
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    $hRebar = ControlGetHandle($hTaskBar, "", "ReBarWindow321")
    $hToolBar = ControlGetHandle($hRebar, "", "ToolbarWindow32" & $iIndex)
    If $hToolBar <> 0x00000000 Then
        If $fShow Then
            _WinAPI_ShowWindow($hToolBar, $SW_SHOW)
        Else
            _WinAPI_ShowWindow($hToolBar, $SW_HIDE)
        EndIf
    EndIf
EndFunc   ;==>_ShowProgramsShowingInTaskBar

Func _TaskBarIndexCount()
    Local $hTaskBar, $hRebar, $hToolBar, $iCount = 0
    $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    $hRebar = ControlGetHandle($hTaskBar, "", "ReBarWindow321")
    While 1
        $hToolBar = ControlGetHandle($hRebar, "", "ToolbarWindow32" & $iCount + 1)
        If $hToolBar = 0x00000000 Then ExitLoop
        $iCount += 1
    WEnd
    Return $iCount
EndFunc   ;==>_ShowProgramsShowingInTaskBar

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Everything works on Vista too, except the Start orb is not hidden in the second demo. Anything where you found this code about rearranging the TaskBarIcons, rather than just showing/hiding them? Or showing/hiding a single particular TaskBarIcon?

Cool stuff :) Thanks

Edit: misread a bit of your code. The TaskBarIcons() functions don't work either (it only hides the arrow that allows you to see the 'hidden' icons), and I mistook ProgramsShowingInTaskbar for TaskBarIcons. And your code answered the question I was trying to get at (I think)...hiding a particular program's taskbar task button (for instance, the AutoIt Help window's button that can minimize and restore the window). But in Vista, there's apparently only 1 ProgramShowingInTaskbar - calling _ShowProgramsShowingInTaskbar(False,1) hides all of the programs, not just the 'first' one. But maybe I misunderstood the code.

Again, thanks. Fun Stuff!

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

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  

×
×
  • Create New...