自动按钮未运行功能

时间:2014-06-11 13:25:27

标签: button user-interface autoit

我有这段代码:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
GUICreate('GUI',550,500)
$CHECKBOXAA = GUICtrlCreateCheckbox("Restore point",20,20,100,20)
$CHECKBOXA2A = GUICtrlCreateCheckbox("Power config",20,40,100,20)
$CHECKBOXA3A = GUICtrlCreateCheckbox("Temp files",20,60,100,20)
$CHECKBOXA4A = GUICtrlCreateCheckbox("",20,80,100,20)
$CHECKBOXA5A = GUICtrlCreateCheckbox("",20,100,100,20)
$CHECKBOXA6A = GUICtrlCreateCheckbox("",20,120,100,20)
$CHECKBOXA7A = GUICtrlCreateCheckbox("",20,140,100,20)
$CHECKBOXA8A = GUICtrlCreateCheckbox("",20,160,100,20)
$CHECKBOXA9A = GUICtrlCreateCheckbox("",20,180,100,20)
$CHECKBOXA10A = GUICtrlCreateCheckbox("",20,200,100,20)
$CHECKBOXA11A = GUICtrlCreateCheckbox("",20,220,100,20)
$CHECKBOXA12A = GUICtrlCreateCheckbox("",20,240,100,20)
$CHECKBOXA13A = GUICtrlCreateCheckbox("",20,260,100,20)
$CHECKBOXA14A = GUICtrlCreateCheckbox("",20,280,100,20)
$CHECKBOXA15A = GUICtrlCreateCheckbox("",20,300,100,20)
$CHECKBOXA16A = GUICtrlCreateCheckbox("",20,320,100,20)
$CHECKBOXA17A = GUICtrlCreateCheckbox("",20,340,100,20)
$CHECKBOXA18A = GUICtrlCreateCheckbox("",20,360,100,20)
$CHECKBOXA19A = GUICtrlCreateCheckbox("",20,380,100,20)
$CHECKBOXA20A = GUICtrlCreateCheckbox("",20,400,100,20)
GUICtrlSetState ( $CHECKBOXAA, 1 )
GUICtrlSetState ( $CHECKBOXA2A, 1 )
GUICtrlSetState ( $CHECKBOXA3A, 1 )
GUICtrlSetState ( $CHECKBOXA4A, 1 )
GUICtrlSetState ( $CHECKBOXA5A, 1 )
GUICtrlSetState ( $CHECKBOXA6A, 1 )
GUICtrlSetState ( $CHECKBOXA7A, 1 )
GUICtrlSetState ( $CHECKBOXA8A, 1 )
GUICtrlSetState ( $CHECKBOXA9A, 1 )
GUICtrlSetState ( $CHECKBOXA10A, 1 )
GUICtrlSetState ( $CHECKBOXA11A, 1 )
GUICtrlSetState ( $CHECKBOXA12A, 1 )
GUICtrlSetState ( $CHECKBOXA13A, 1 )
GUICtrlSetState ( $CHECKBOXA14A, 1 )
GUICtrlSetState ( $CHECKBOXA15A, 1 )
GUICtrlSetState ( $CHECKBOXA16A, 1 )
GUICtrlSetState ( $CHECKBOXA17A, 1 )
GUICtrlSetState ( $CHECKBOXA18A, 1 )
GUICtrlSetState ( $CHECKBOXA19A, 1 )
GUICtrlSetState ( $CHECKBOXA20A, 1 )


GUICtrlCreateButton("More info", 120,20,50,20)
GUICtrlSetOnEvent(-1, "info")

GUISetState()

Func info()
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    Send("This will create a sysstem restore point. So you can recover your PC in the very unlikely chance something will go wrong.")
EndFunc



While 1
    $MSGAA = GUIGetMsg()
    If $MSGAA = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXAA) = 1 Then
        FileDelete ( "Func\FuncAA.dll" )
        $fileAA = FileOpen("Func\FuncAA.dll", 1)
        FileWrite($fileAA, "1")
        FileClose($fileAA)
     Else
        FileDelete ( "Func\FuncAA.dll" )
        $fileAA = FileOpen("Func\FuncAA.dll", 1)
        FileWrite($fileAA, "0")
        FileClose($fileAA)
    EndIf
    $MSGA2A = GUIGetMsg()
    If $MSGA2A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA2A) = 1 Then
        FileDelete ( "Func\FuncA2A.dll" )
        $fileA2A = FileOpen("Func\FuncA2A.dll", 1)
        FileWrite($fileA2A, "1")
        FileClose($fileA2A)
     Else
        FileDelete ( "Func\FuncA2A.dll" )
        $fileA2A = FileOpen("Func\FuncA2A.dll", 1)
        FileWrite($fileA2A, "0")
        FileClose($fileA2A)
    EndIf
    $MSGA3A = GUIGetMsg()
    If $MSGA3A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA3A) = 1 Then
        FileDelete ( "Func\FuncA3A.dll" )
        $fileA3A = FileOpen("Func\FuncA3A.dll", 1)
        FileWrite($fileA3A, "1")
        FileClose($fileA3A)
     Else
        FileDelete ( "Func\FuncA3A.dll" )
        $fileA3A = FileOpen("Func\FuncA3A.dll", 1)
        FileWrite($fileA3A, "0")
        FileClose($fileA3A)
    EndIf
    $MSGA4A = GUIGetMsg()
    If $MSGA4A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA4A) = 1 Then
        FileDelete ( "Func\FuncA4A.dll" )
        $fileA4A = FileOpen("Func\FuncA4A.dll", 1)
        FileWrite($fileA4A, "1")
        FileClose($fileA4A)
     Else
        FileDelete ( "Func\FuncA4A.dll" )
        $fileA4A = FileOpen("Func\FuncA4A.dll", 1)
        FileWrite($fileA4A, "0")
        FileClose($fileA4A)
    EndIf
    $MSGA5A = GUIGetMsg()
    If $MSGA5A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA5A) = 1 Then
        FileDelete ( "Func\FuncA5A.dll" )
        $fileA5A = FileOpen("Func\FuncA5A.dll", 1)
        FileWrite($fileA5A, "1")
        FileClose($fileA5A)
     Else
        FileDelete ( "Func\FuncA5A.dll" )
        $fileA5A = FileOpen("Func\FuncA5A.dll", 1)
        FileWrite($fileA5A, "0")
        FileClose($fileA5A)
    EndIf
    $MSGA6A = GUIGetMsg()
    If $MSGA6A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA6A) = 1 Then
        FileDelete ( "Func\FuncA6A.dll" )
        $fileA6A = FileOpen("Func\FuncA6A.dll", 1)
        FileWrite($fileA6A, "1")
        FileClose($fileA6A)
     Else
        FileDelete ( "Func\FuncA6A.dll" )
        $fileA6A = FileOpen("Func\FuncA6A.dll", 1)
        FileWrite($fileA6A, "0")
        FileClose($fileA6A)
    EndIf
    $MSGA7A = GUIGetMsg()
    If $MSGA7A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA7A) = 1 Then
        FileDelete ( "Func\FuncA7A.dll" )
        $fileA7A = FileOpen("Func\FuncA7A.dll", 1)
        FileWrite($fileA7A, "1")
        FileClose($fileA7A)
     Else
        FileDelete ( "Func\FuncA7A.dll" )
        $fileA7A = FileOpen("Func\FuncA7A.dll", 1)
        FileWrite($fileA7A, "0")
        FileClose($fileA7A)
    EndIf
    $MSGA8A = GUIGetMsg()
    If $MSGA8A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA8A) = 1 Then
        FileDelete ( "Func\FuncA8A.dll" )
        $fileA8A = FileOpen("Func\FuncA8A.dll", 1)
        FileWrite($fileA8A, "1")
        FileClose($fileA8A)
     Else
        FileDelete ( "Func\FuncA8A.dll" )
        $fileA8A = FileOpen("Func\FuncA8A.dll", 1)
        FileWrite($fileA8A, "0")
        FileClose($fileA8A)
    EndIf
    $MSGA9A = GUIGetMsg()
    If $MSGA9A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA9A) = 1 Then
        FileDelete ( "Func\FuncA9A.dll" )
        $fileA9A = FileOpen("Func\FuncA9A.dll", 1)
        FileWrite($fileA9A, "1")
        FileClose($fileA9A)
     Else
        FileDelete ( "Func\FuncA9A.dll" )
        $fileA9A = FileOpen("Func\FuncA9A.dll", 1)
        FileWrite($fileA9A, "0")
        FileClose($fileA9A)
    EndIf
    $MSGA10A = GUIGetMsg()
    If $MSGA10A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA10A) = 1 Then
        FileDelete ( "Func\FuncA10A.dll" )
        $fileA10A = FileOpen("Func\FuncA10A.dll", 1)
        FileWrite($fileA10A, "1")
        FileClose($fileA10A)
     Else
        FileDelete ( "Func\FuncA10A.dll" )
        $fileA10A = FileOpen("Func\FuncA10A.dll", 1)
        FileWrite($fileA10A, "0")
        FileClose($fileA10A)
    EndIf
    $MSGA11A = GUIGetMsg()
    If $MSGA11A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA11A) = 1 Then
        FileDelete ( "Func\FuncA11A.dll" )
        $fileA11A = FileOpen("Func\FuncA11A.dll", 1)
        FileWrite($fileA11A, "1")
        FileClose($fileA11A)
     Else
        FileDelete ( "Func\FuncA11A.dll" )
        $fileA11A = FileOpen("Func\FuncA11A.dll", 1)
        FileWrite($fileA11A, "0")
        FileClose($fileA11A)
    EndIf
    $MSGA12A = GUIGetMsg()
    If $MSGA12A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA12A) = 1 Then
        FileDelete ( "Func\FuncA12A.dll" )
        $fileA12A = FileOpen("Func\FuncA12A.dll", 1)
        FileWrite($fileA12A, "1")
        FileClose($fileA12A)
     Else
        FileDelete ( "Func\FuncA12A.dll" )
        $fileA12A = FileOpen("Func\FuncA12A.dll", 1)
        FileWrite($fileA12A, "0")
        FileClose($fileA12A)
    EndIf
    $MSGA13A = GUIGetMsg()
    If $MSGA13A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA13A) = 1 Then
        FileDelete ( "Func\FuncA13A.dll" )
        $fileA13A = FileOpen("Func\FuncA13A.dll", 1)
        FileWrite($fileA13A, "1")
        FileClose($fileA13A)
     Else
        FileDelete ( "Func\FuncA13A.dll" )
        $fileA13A = FileOpen("Func\FuncA13A.dll", 1)
        FileWrite($fileA13A, "0")
        FileClose($fileA13A)
    EndIf
    $MSGA14A = GUIGetMsg()
    If $MSGA14A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA14A) = 1 Then
        FileDelete ( "Func\FuncA14A.dll" )
        $fileA14A = FileOpen("Func\FuncA14A.dll", 1)
        FileWrite($fileA14A, "1")
        FileClose($fileA14A)
     Else
        FileDelete ( "Func\FuncA14A.dll" )
        $fileA14A = FileOpen("Func\FuncA14A.dll", 1)
        FileWrite($fileA14A, "0")
        FileClose($fileA14A)
    EndIf
    $MSGA15A = GUIGetMsg()
    If $MSGA15A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA15A) = 1 Then
        FileDelete ( "Func\FuncA15A.dll" )
        $fileA15A = FileOpen("Func\FuncA15A.dll", 1)
        FileWrite($fileA15A, "1")
        FileClose($fileA15A)
     Else
        FileDelete ( "Func\FuncA15A.dll" )
        $fileA15A = FileOpen("Func\FuncA15A.dll", 1)
        FileWrite($fileA15A, "0")
        FileClose($fileA15A)
    EndIf
    $MSGA16A = GUIGetMsg()
    If $MSGA16A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA16A) = 1 Then
        FileDelete ( "Func\FuncA16A.dll" )
        $fileA16A = FileOpen("Func\FuncA16A.dll", 1)
        FileWrite($fileA16A, "1")
        FileClose($fileA16A)
     Else
        FileDelete ( "Func\FuncA16A.dll" )
        $fileA16A = FileOpen("Func\FuncA16A.dll", 1)
        FileWrite($fileA16A, "0")
        FileClose($fileA16A)
    EndIf
    $MSGA17A = GUIGetMsg()
    If $MSGA17A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA17A) = 1 Then
        FileDelete ( "Func\FuncA17A.dll" )
        $fileA17A = FileOpen("Func\FuncA17A.dll", 1)
        FileWrite($fileA17A, "1")
        FileClose($fileA17A)
     Else
        FileDelete ( "Func\FuncA17A.dll" )
        $fileA17A = FileOpen("Func\FuncA17A.dll", 1)
        FileWrite($fileA17A, "0")
        FileClose($fileA17A)
    EndIf
    $MSGA18A = GUIGetMsg()
    If $MSGA18A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA18A) = 1 Then
        FileDelete ( "Func\FuncA18A.dll" )
        $fileA18A = FileOpen("Func\FuncA18A.dll", 1)
        FileWrite($fileA18A, "1")
        FileClose($fileA18A)
     Else
        FileDelete ( "Func\FuncA18A.dll" )
        $fileA18A = FileOpen("Func\FuncA18A.dll", 1)
        FileWrite($fileA18A, "0")
        FileClose($fileA18A)
    EndIf
    $MSGA19A = GUIGetMsg()
    If $MSGA19A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA19A) = 1 Then
        FileDelete ( "Func\FuncA19A.dll" )
        $fileA19A = FileOpen("Func\FuncA19A.dll", 1)
        FileWrite($fileA19A, "1")
        FileClose($fileA19A)
     Else
        FileDelete ( "Func\FuncA19A.dll" )
        $fileA19A = FileOpen("Func\FuncA19A.dll", 1)
        FileWrite($fileA19A, "0")
        FileClose($fileA19A)
    EndIf
    $MSGA20A = GUIGetMsg()
    If $MSGA20A = -3 Then
        Exit
    EndIf
    If GUICtrlRead($CHECKBOXA20A) = 1 Then
        FileDelete ( "Func\FuncA20A.dll" )
        $fileA20A = FileOpen("Func\FuncA20A.dll", 1)
        FileWrite($fileA20A, "1")
        FileClose($fileA20A)
     Else
        FileDelete ( "Func\FuncA20A.dll" )
        $fileA20A = FileOpen("Func\FuncA20A.dll", 1)
        FileWrite($fileA20A, "0")
        FileClose($fileA20A)
    EndIf






    Sleep(1000)
WEnd

它创建了一个按钮More info但它似乎没有运行该功能。有没有人知道我做错了什么。

问题似乎在这里:

GUICtrlCreateButton("More info", 120,20,50,20)
GUICtrlSetOnEvent(-1, "info")

GUISetState()

Func info()
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    Send("This will create a sysstem restore point. So you can recover your PC in the very unlikely chance something will go wrong.")
EndFunc

1 个答案:

答案 0 :(得分:2)

要使用OnEvent GUI功能,您需要设置:

Opt("GUIOnEventMode", 1)