有没有办法把菜单里的选项和GUI窗口上的按钮关联起来
如题,写了个GUI的界面,现在想把一个按钮的功能和菜单上的选项关联起来,实现同一个效果,请问有没有办法实现[ 本帖最后由 wbsgege 于 2008-10-6 14:28 编辑 ] 有! 调用同一个功能函数
#NoTrayIcon
#include-once
#include <IE.AU3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{F7}", "_RUN_STOP_SCRIPT")
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
$Show = TrayCreateItem("隐藏窗口")
TrayItemSetOnEvent($Show, "_Tray_Menu_Show")
TrayCreateItem("")
$SLEEP = TrayCreateItem("暂停辅助")
TrayItemSetOnEvent($SLEEP, "_RUN_STOP_SCRIPT")
TrayItemSetState($SLEEP, $TRAY_CHECKED)
TrayCreateItem("")
$Quit = TrayCreateItem("退出辅助")
TrayItemSetOnEvent($Quit, "_Tray_Menu_Quit")
TraySetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gui_event_minimize
_Tray_Menu_Show()
.
.
.
Case $Checkbox6
If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then
GUICtrlSetState($Checkbox7, $GUI_ENABLE)
Else
GUICtrlSetState($Checkbox7, $GUI_DISABLE)
EndIf
Case $Button3
_RUN_STOP_SCRIPT()
Case $Button4
Exit
Case $Edit1
EndSwitch
WEnd
Func _Tray_Menu_Show()
If TrayItemGetText($Show) = "显示窗口" Then
TrayItemSetText($Show, "隐藏窗口")
WinSetState($Form1, "", @SW_SHOW)
WinActivate($Form1, "")
Else
TrayItemSetText($Show, "显示窗口")
WinSetState($Form1, "", @SW_HIDE)
EndIf
EndFunc
Func _Tray_Menu_Quit()
Exit
EndFunc
Func _RUN_STOP_SCRIPT()
$PAUSE = Not $PAUSE
If $PAUSE = 0 Then
TrayItemSetState($SLEEP, $TRAY_UNCHECKED)
Else
TrayItemSetState($SLEEP, $TRAY_CHECKED)
EndIf
If $PAUSE = 0 Then
GUICtrlSetColor($Button3, 0x0000FF)
GUICtrlSetTip($Button3, "暂停辅助程序,热键(F7)")
GUICtrlSetData($Button3, "暂停辅助")
Else
GUICtrlSetColor($Button3, 0xFF0000)
GUICtrlSetTip($Button3, "开始辅助程序,热键(F7)")
GUICtrlSetData($Button3, "开始辅助")
EndIf
EndFunc
[ 本帖最后由 liongodmien 于 2008-9-26 20:56 编辑 ]
页:
[1]