#Include <Constants.au3>
#NoTrayIcon
Opt("TrayMenuMode",1)
$Hy = IniRead(@ScriptDir& "" &"Config.ini", "设置", "自动激活", "")
$checkeditem = TrayCreateItem("自动激活")
If $Hy = "是" Then
TrayItemSetState($checkeditem,$TRAY_CHECKED)
ElseIf $Hy = "否" Then
TrayItemSetState($checkeditem,$TRAY_UNCHECKED)
EndIf
TrayCreateItem("")
$exititem = TrayCreateItem("退出")
TraySetState()
While 1
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $checkeditem
If TrayItemGetState($checkeditem) = 65 Then
IniWrite(@ScriptDir& "" &"Config.ini", "设置", "自动激活", "是")
ElseIf TrayItemGetState($checkeditem) = 68 Then
IniWrite(@ScriptDir& "" &"Config.ini", "设置", "自动激活", "否")
Dim $i
$i = $i + 1
If $i = 1 Then
If $Hy = "否" Then
TrayItemSetState($checkeditem,$TRAY_CHECKED)
IniWrite(@ScriptDir& "" &"Config.ini", "设置", "自动激活", "是")
EndIf
$i = 1
EndIf
EndIf
Case $msg = $exititem
ExitLoop
EndSelect
WEnd
Exit
我自己写了一个,不知道这样对不对呢?还有更好的方法吗? |