Sign in to follow this  
Followers 0

Add a static button to the TaskBar (xp/Win7)

3 posts in this topic

Posted

Hi,

I am trying to add a button next to the start menu on xp / win7 and show a gui once it is clicked.

i added a band to the TaskBar rebar but i got to issues:

1. I can not figure out the right index to place it after the Start button (it is different between XP and Win7 i think)

2. in WIN7 is seems that the new band is not fully placed as the task bar is it below the regular quick start icons

any idea ?

Local $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
Local $hRebar =  ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ReBarWindow321")
    
local $Rehighet = _GUICtrlRebar_GetBarHeight($hReBar)
$btn = _GUICtrlButton_Create($hRebar, "",  0,0,35, _GUICtrlRebar_GetBarHeight($hReBar))
local $indx = _GUICtrlRebar_GetBandCount($hReBar) 
    
_GUICtrlReBar_AddBand ($hRebar,  $btn , 25,25, "" ,  $indx, $RBBS_CHILDEDGE  + $RBBS_NOGRIPPER + $RBBS_FIXEDSIZE)
    
_WinAPI_SetParent($btn,$hReBar)
GUISetState(@SW_SHOW,$hTaskBar)

Share this post


Link to post
Share on other sites



Posted

ok getting there, manged to pin a button on the taskbar in win7 but it crashes XP ...

anyone ?

Local $hgui, $hReBar, $btn,$chhnd
    Local $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
    Local $hRebar =  ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ReBarWindow321")
    local $Rehighet = _GUICtrlRebar_GetBarHeight($hReBar)
    
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    ;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    local $indx =  _GUICtrlRebar_GetBandCount($hReBar) 
    local $NewBand = 1
    
    $hgui = GUICreate("", 30, _GUICtrlRebar_GetBarHeight($hReBar), Default, Default,  BitOR($WS_POPUP, $WS_EX_TOOLWINDOW))
    $btn = _GUICtrlButton_Create($hgui, "OK", 0,0,30, _GUICtrlRebar_GetBarHeight($hReBar))
    _GUICtrlReBar_AddBand ($hRebar,  $hgui , 30,_GUICtrlRebar_GetBarHeight($hReBar), "" ,$indx, $RBBS_CHILDEDGE  + $RBBS_NOGRIPPER + $RBBS_FIXEDSIZE)
    _GUICtrlRebar_MoveBand ($hRebar, $indx,$NewBand)

    ;_WinAPI_SetParent($hgui,$hTaskBar)
    ;GUISetState()


;#debug info to Console
  ConsoleWrite("==========================" & @CRLF & _GUICtrlRebar_GetBandCount($hReBar) & @CRLF )
    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar)-1
    ConsoleWrite    ("============================================" & @CRLF)
        ConsoleWrite ("Band Index " & $x & @TAB & "ID: " & _GUICtrlRebar_GetBandID($hReBar, $x) & @TAB &  "Name:" & _GUICtrlRebar_GetBandText ($hReBar, $x) & @CRLF)
    Next

    While 1
    WEnd


Func _Exit()
        _GUICtrlRebar_DeleteBand ($hReBar,$NewBand)
        Exit
EndFunc   ;==>_Exit


; React on a button click
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""
    
    Switch $hCtrl
        Case $btn, $rdo, $chk
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "$BN_CLICKED" & @CRLF
                    _exit ()
                 Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            
            ConsoleWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites

Posted

still i can get it working in Xp - anyone ?

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

  • Recently Browsing   0 members

    No registered users viewing this page.