回复 20# zzmxd
怪不得如此混乱~~
你主要的问题是无法同时响应GUI窗口和托盘菜单的命令吧??
我也另外帮你拼凑了个,你依样画葫芦吧~~
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt('TrayOnEventMode', 1)
Opt('traymenumode', 3)
$Form1 = GUICreate("GUI_Tray", 200, 100, 190, 120, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Click me!", 24, 16, 153, 57)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
$test = TrayCreateItem('test!')
TrayItemSetOnEvent(-1, '_Tray')
$exit = TrayCreateItem('exit')
TrayItemSetOnEvent(-1, '_Tray')
While 1
Sleep(1000000)
WEnd
Func Button1Click()
MsgBox(0x40000, 0, 'GUI消息响应!')
EndFunc ;==>Button1Click
Func Form1Close()
MsgBox(0x40000, 0, 'GUI窗口关闭退出', 3)
Exit
EndFunc ;==>Form1Close
Func _Tray()
Switch @TRAY_ID
Case $test
MsgBox(0x40000, 0, '托盘事件响应!')
Case $exit
MsgBox(0x40000, 0, '托盘菜单退出!', 3)
Exit
EndSwitch
EndFunc ;==>_Tray
其实我自己平时是很少用托盘的~~ |