wmysbbs 发表于 2009-12-12 01:04:44

托盘菜单项是否勾选判断

#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
我自己写了一个,不知道这样对不对呢?还有更好的方法吗?

wmysbbs 发表于 2009-12-12 21:35:20

周末无人。。。。

wmysbbs 发表于 2009-12-12 21:42:43

这样单独设置没有问题,但应用到写好的程序中就出错了!!
页: [1]
查看完整版本: 托盘菜单项是否勾选判断