自动制作按钮做两件事。每隔一次点击一次

时间:2013-11-29 12:04:53

标签: autoit

我有这段代码:

        If $servers = "RUNNING" Then
            GUISwitch($GUI)
            GUISetState(@SW_SHOW, $GUI)
        Else
            MsgBox(16, "Failure", "The server isn't running")
        EndIf

        If $servers = "RUNNING" Then
            GUISwitch($GUI)
            GUISetState(@SW_HIDE, $GUI)
        Else
            MsgBox(16, "Failure", "The server isn't running")
        EndIf

一个将显示GUI,另一个将隐藏GUI。我有一个按钮,应该做一个或另一个。如何每隔一段时间将按钮设置为一个或另一个?像gui被隐藏的东西,然后显示。如果显示,则隐藏。

1 个答案:

答案 0 :(得分:2)

#Region    ;************ Includes ************
#Include <GUIConstantsEx.au3>
#EndRegion ;************ Includes ************

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.8.1
    Author:         myName

    Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

; example 1
Example1()
Func Example1()
    Local $msg

    $GUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered
    GUISetState(@SW_SHOW) ; will display an empty dialog box
    $b = GUICtrlCreateButton('switch State', 10, 10, 100, 20)

        $GUI2 = GUICreate("CHILD", 110, 10, 100, 20) ; will create a dialog box that when displayed is centered

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $b Then
            If BitAND(WinGetState($GUI2), 2) Then
                GUISetState(@SW_HIDE, $GUI2)
            Else
                GUISetState(@SW_SHOW, $GUI2)
            EndIf
        EndIf

    WEnd
    GUIDelete()
EndFunc   ;==>Example1