Ownership.
Here are a few lines of code from an incomplete script I stopped writing that steals the Windows TaskBar and places it onto my own GUI (Among other things, but all you really need is the TaskBar part).
Code:
ControlGet FauxTaskBar, Hwnd, , ToolbarWindow322, ahk_class Shell_TrayWnd ; TaskBar
FauxTaskBarParent := GetParent(FauxTaskBar) ; Parent of TaskBar
TaskBarLength := A_ScreenWidth - 80
BarHeight = 30
y := A_ScreenHeight - BarHeight
Gui -Caption +ToolWindow +AlwaysOnTop +0x02000000 ; WS_CLIPCHILDREN
Gui Show, W%TaskBarLength% H%BarHeight% x80 y%y%, NewTaskBar
StartButtonPos := y - 30
StartButtonHeight := BarHeight + 55
Gui 2:-Caption +ToolWindow
Gui 2:Show, w1000 h%StartButtonHeight% x0 y%StartButtonPos%, StartButtonGui
WinSet Region, 0-0 w82 h82 E, StartButtonGui
WinSet Transparent, 100, StartButtonGui
FauxGuiWindow := WinExist("NewTaskBar")
GoSub, AddTools
Return
ShowStartMenu: ; Show real startmenu using my own button.
SendMessage 0x112, 0xF130 ; WM_SYSCOMMAND = 0x112 SC_TASKLIST = 0xF130
Return
AddTools:
SetParent(FauxTaskBar, FauxGuiWindow) ; Steal ownership
ControlMove, , 5, , , , ahk_id %FauxTaskBar%
WinHide, ahk_class Shell_TrayWnd ; Hide real TaskBar
Return
RestoreTools:
SetParent(FauxTaskBar, FauxTaskBarParent) ; Reset the owner
Return
GetParent(FauxControl) ; Get current control owner.
{
Return DllCall("GetParent", "UInt", FauxControl)
}
SetParent(FauxControl, FauxNewParent) ; For changing control ownership.
{
Return DllCall("SetParent", "UInt", FauxControl, "UInt", FauxNewParent)
}
^r::
RestoreExit:
GoSub RestoreTools
WinShow ahk_class Shell_TrayWnd ; Show real TaskBar
ExitApp
OnMessage(0x7E, "WM_DISPLAYCHANGE") ; In case user changes screen resolution
Return
WM_DISPLAYCHANGE() ; In case user changes screen resolution
{
Reload
}
Not sure if that helps you any, but it shouldn't be too hard to figure out how to get Tray items.
Edit: If you put a picture in "Gui 2", clicking on it will act like clicking the start button.
To end the script and return ownership to Windows... Press "CTRL+r".