本帖最后由 痒痒 于 2009-12-29 14:49 编辑 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GuiOnEventMode", 1)
Opt("traymenumode", 1)
Opt("trayoneventmode", 1)
$show = TrayCreateItem("显示主窗口")
TrayItemSetOnEvent($show, "traymsg")
$exit = TrayCreateItem("退出")
TrayItemSetOnEvent($exit, "traymsg")
TraySetState()
#Region ### START Koda GUI section ### Form=
Dim $Button[4]
$Form1 = GUICreate("Form1", 314, 137, 326, 318)
$Button[0] = GUICtrlCreateButton("注册表", 24, 32, 121, 33, 0)
$Button[1] = GUICtrlCreateButton("计算器", 168, 32, 121, 33, 0)
$Button[2] = GUICtrlCreateButton("添加/删除", 24, 80, 121, 33, 0)
$Button[3] = GUICtrlCreateButton("最小到托盘", 168, 80, 121, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($gui_event_close, "guimsg")
For $i = 0 To 3
GUICtrlSetOnEvent($Button[$i], "guimsg")
Next
While 1
Sleep(1)
WEnd
Func guimsg()
Switch @GUI_CtrlId
Case $gui_event_close
Exit
Case $Button[0]
Run("regedit.exe")
Case $Button[1]
Run("calc.exe")
Case $Button[2]
Run("control.exe appwiz.cpl")
Case $Button[3]
GUISetState(@SW_HIDE, $Form1)
EndSwitch
EndFunc ;==>guimsg
Func traymsg()
Switch @TRAY_ID
Case $show
GUISetState(@SW_SHOW, $Form1)
Case $exit
Exit
EndSwitch
EndFunc ;==>traymsg
怎么将“traymsg()”这个自定义函数放到“guimsg()”里,但又能正常运行。可以这样再精简下么? |