You can use it to modify toolbars from other applications. For example, the TaskBar has several ToolBars. These functions need the hwnd of the toolbar control to work.
Many thanks to Sean for his
Taskbar/TrayIcon.ahk scripts; of which most of this is based on.
I will later extend this to include more toolbar messages documented in MSDN.
Note: This requires majkinetor's recently updated
RemoteBuffer module in your
library.
Save it as TB.ahk in your library for other scripts to use.
Code:
/*
############################################################################# Information
By Infogulch
See this url for more information: http://www.autohotkey.com/forum/viewtopic.php?t=39389
!! Requires RemoteBuf.ahk in your library. Found here: http://www.autohotkey.com/forum/topic12251.html
Special thanks to Sean, majkinetor, and ahklerner
############################################################################# ToolBar Styles Reference
TBSTYLE_BUTTON := 0x0
TBSTYLE_SEP := 0x1
TBSTYLE_EX_DRAWDDARROWS := 0x1
TBSTYLE_CHECK := 0x2
TBSTYLE_GROUP := 0x4
TBSTYLE_DROPDOWN := 0x8
TBSTYLE_EX_MIXEDBUTTONS := 0x8
TBSTYLE_AUTOSIZE := 0x10
TBSTYLE_EX_HIDECLIPPEDBUTTONS := 0x10
TBSTYLE_NOPREFIX := 0x20
TBSTYLE_EX_DOUBLEBUFFER := 0x80
TBSTYLE_TOOLTIPS := 0x100
TBSTYLE_WRAPABLE := 0x200
TBSTYLE_ALTDRAG := 0x400
TBSTYLE_FLAT := 0x800
TBSTYLE_LIST := 0x1000
TBSTYLE_CUSTOMERASE := 0x2000
TBSTYLE_REGISTERDROP := 0x4000
TBSTYLE_TRANSPARENT := 0x8000
TBSTYLE_CHECKGROUP := (TBSTYLE_GROUP Or TBSTYLE_CHECK)
############################################################################# ToolBar Functions
*/
TB_Hide(hwnd, idn, bHide = True) {
SendMessage, 0x404, idn, bHide, , ahk_id %hwnd% ; TB_HIDEBUTTON
return ErrorLevel
}
TB_Delete(hwnd, idx) {
SendMessage, 0x416, idx, 0, , ahk_id %hwnd% ; TB_DELETEBUTTON
return ErrorLevel
}
TB_Move(hwnd, idxOld, idxNew) {
; Shift + Swap
SendMessage, 0x452, idxOld, idxNew, , ahk_id %hwnd% ; TB_MOVEBUTTON
}
TB_GetHotItem(hwnd) {
SendMessage, 0x447, 0, 0, , ahk_id %hwnd% ; TB_GETHOTITEM
Return ErrorLevel << 32 >> 32
}
TB_SetInsertMark(hwnd, idx, side=0) { ;idx is 0 based, so the first button would be 0. use -1 to remove; 0 on the left side, 1 on the right side
idPar := DllCall("GetParent", uint, hwnd)
RemoteBuf_Open(bufData, idPar, 8)
RemoteBuf_Write(bufData, idx, 4)
RemoteBuf_Write(bufData, side := !!side, 4, 4)
SendMessage, 0x450, 0, RemoteBuf_Get(BufData, "adr"), , ahk_id %hwnd%
return ErrorLevel, RemoteBuf_Close(BufData)
}
TB_SetInsertMarkColor(hwnd, rgb) { ; COLORREF: 0x00bbggrr
SendMessage, (0x400 + 88), 0, (rgb & 0xff << 16) | (rgb >> 8 & 0xff << 8) | (rgb >> 16 & 0xff)
, , ahk_id %hwnd% ;TB_SETINSERTMARKCOLOR := (WM_USER + 88)
return ErrorLevel
}
TB_SetStyle(hwnd, styles) {
SendMessage, 0x438, 0, styles, , ahk_id %hwnd%
return ErrorLevel
}
TB_GetStyle(hwnd) {
SendMessage, 0x439, 0, , , ahk_id %hwnd% ;TB_GETSTYLE
return ErrorLevel
}
TB_ChangeStyle(hwnd, add = 0, remove = 0) {
return TB_SetStyle(hwnd, TB_GetStyle(hwnd) | add ~ remove)
}
TB_GetItemRect(hwnd, idx, ByRef RECT) {
idPar := DllCall("GetParent", uint, hwnd)
RemoteBuf_Open(bufData, idPar, 16)
SendMessage, 0x41D, idx, RemoteBuf_Get(bufData, "adr"),, ahk_id %hwnd%
err := errorlevel
RemoteBuf_Read(bufData, RECT, 16, 0 )
RemoteBuf_Close(BufData)
return err
}
TB_ButtonCount(hwnd) {
SendMessage, (0x400 + 24), , , , ahk_id %hwnd%
return ErrorLevel
}
TB_AutoSize(hwnd) {
SendMessage, (0x400 + 33), , , , ahk_id %hwnd% ;no return value
}
MSDN Toolbar Control
