; Holger
; http://www.autoitscript.com/forum/topic/20967-guitray-menu-with-icons-and-colors/
#include "ModernMenuRaw.au3"

#NoTrayIcon
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 7)

_SetFlashTimeOut(250)
If @Compiled Then
	$nTrayIcon = _TrayIconCreate("Моя программа", @AutoItExe, -1)
Else
	$nTrayIcon = _TrayIconCreate("Моя программа", "shell32.dll", -209)
EndIf
_TrayCreateContextMenu()
$bUseAdvTrayMenu = False

$hMenu = _TrayCreateMenu('Меню') ; меню
_TrayItemSetIcon(-1, "shell32.dll", -5)
_TrayCreateItem("")

_TrayCreateItem('Открыть', $hMenu)
_TrayItemSetIcon(-1, "shell32.dll", -5)
_TrayCreateItem("", $hMenu)

For $i = 1 To 10
	_TrayCreateItem('Пункт ' & $i, $hMenu)
	_TrayItemSetIcon(-1, "shell32.dll", -$i)
Next

$action = _TrayCreateMenu('Вложенное')
_TrayItemSetIcon(-1, "shell32.dll", -177)

$nUpd = _TrayCreateItem('Перезапуск', $action)
_TrayItemSetIcon(-1, "shell32.dll", -147)

$nSave = _TrayCreateItem('Сохранить', $action)
_TrayItemSetIcon(-1, "shell32.dll", -195)

$nClose = _TrayCreateItem('Закрыть', $action)
_TrayItemSetIcon(-1, "shell32.dll", -110)

$nAdd = _TrayCreateItem('Добавить', $action)
_TrayItemSetIcon(-1, "shell32.dll", -5)

$nFolder = _TrayCreateItem('Папка', $action)
_TrayItemSetIcon(-1, "shell32.dll", -4)

$nSet = _TrayCreateItem('Настройка', $action)
_TrayItemSetIcon(-1, "shell32.dll", -91)

$nAbout = _TrayCreateItem('О программе')
_TrayItemSetIcon(-1, "shell32.dll", -222)

$nExit = _TrayCreateItem('Выход')
GUICtrlSetOnEvent(-1, "_Quit") ; присваивает функцию пункту
_TrayItemSetIcon(-1, "shell32.dll", -216)

_TrayIconSetState()

While 1
	Sleep(10000)
WEnd

Func _Quit()
	_TrayIconDelete($nTrayIcon)
	Exit
EndFunc