#include <Constants.au3>
Opt("TrayMenuMode", 1)
Local $sRegPath = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
GUICreate("Form1", 280, 250)
$Yes = TrayCreateItem("跟随系统启动")
$No = TrayCreateItem("不随系统启动")
$exit = TrayCreateItem("退出")
If RegRead($sRegPath, @ScriptName) <> '' Then
TrayItemSetState($Yes, $TRAY_CHECKED)
Else
TrayItemSetState($No, $TRAY_CHECKED)
EndIf
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
EndSwitch
$msg = TrayGetMsg()
Select
Case $msg = $exit
Exit
Case $msg = $Yes
RegWrite($sRegPath, @ScriptName, 'REG_SZ', '"' & @ScriptFullPath & '" /AUTO')
MsgBox(0, '状态:', '跟随系统启动')
Case $msg = $No
RegDelete($sRegPath, @ScriptName)
MsgBox(0, '状态:', '不随系统启动')
EndSelect
WEnd
|