启动GUI

时间:2017-09-02 18:52:54

标签: user-interface autoit

一直在尝试做GUI。我无法启动GUI。它会打开,但不会运行案例$Start

#include-once
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1     = GUICreate("rss send", 274, 394, -1, -1)
$Food        = GUICtrlCreateInput("", 24, 88, 225, 21)
$Marketmax   = GUICtrlCreateLabel("Marketplace maximum", 24, 8, 109, 17)
$Marketplace = GUICtrlCreateInput("", 24, 32, 225, 21)
$Foodtext    = GUICtrlCreateLabel("Food", 24, 64, 28, 17)
$Woodtext    = GUICtrlCreateLabel("Wood", 24, 120, 33, 17)
$Wood        = GUICtrlCreateInput("", 24, 144, 225, 21)
$Irontext    = GUICtrlCreateLabel("Iron", 24, 176, 22, 17)
$Iron        = GUICtrlCreateInput("", 24, 200, 225, 21)
$Stonetext   = GUICtrlCreateLabel("Stone", 24, 232, 32, 17)
$Stone       = GUICtrlCreateInput("", 24, 256, 225, 21)
$Silvertext  = GUICtrlCreateLabel("Silver", 24, 288, 30, 17)
$Silver      = GUICtrlCreateInput("", 24, 312, 225, 21)
$Start       = GUICtrlCreateButton("Start", 24, 344, 89, 33)
$Exit        = GUICtrlCreateButton("Exit", 152, 344, 89, 33)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit
            Exit

        Case $Start
            Func start()
                For $1 = 1 to $Food / $Marketplace
                    MouseClickDrag("left",731,228,891,228,10)
                    sleep(2000)
                    MouseClick("left",1011,882)
                    sleep(2000)
                Next
            EndFunc
    EndSwitch
WEnd

2 个答案:

答案 0 :(得分:0)

您可以使用GUISetOnEventHere是描述和示例。

在你的情况下:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=c:\users\regin\desktop\auto it\rss send.kxf
$Form1_1 = GUICreate("rss send", 274, 394, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Food = GUICtrlCreateInput("", 24, 88, 225, 21)
$Marketmax = GUICtrlCreateLabel("Marketplace maximum", 24, 8, 109, 17)
$Marketplace = GUICtrlCreateInput("", 24, 32, 225, 21)
$Foodtext = GUICtrlCreateLabel("Food", 24, 64, 28, 17)
$Woodtext = GUICtrlCreateLabel("Wood", 24, 120, 33, 17)
$Wood = GUICtrlCreateInput("", 24, 144, 225, 21)
$Irontext = GUICtrlCreateLabel("Iron", 24, 176, 22, 17)
$Iron = GUICtrlCreateInput("", 24, 200, 225, 21)
$Stonetext = GUICtrlCreateLabel("Stone", 24, 232, 32, 17)
$Stone = GUICtrlCreateInput("", 24, 256, 225, 21)
$Silvertext = GUICtrlCreateLabel("Silver", 24, 288, 30, 17)
$Silver = GUICtrlCreateInput("", 24, 312, 225, 21)
$Start = GUICtrlCreateButton("Start", 24, 344, 89, 33)
GUICtrlSetOnEvent(-1, "Start")
$Exit = GUICtrlCreateButton("Exit", 152, 344, 89, 33)
GUICtrlSetOnEvent(-1, "Close")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   sleep(100)
WEnd

Func Start()   
   consolewrite("Start Function" & @CRLF)
   for $1 = 1 to $Food / $Marketplace
      MouseClickDrag("left",731,228,891,228,10)
      sleep(2000)
      MouseClick("left",1011,882)
      sleep(2000)
   next
EndFunc

Func Close()
   exit
EndFunc

答案 1 :(得分:0)

试一试。你不能在while循环中声明函数。

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1_1 = GUICreate("rss send", 274, 394, -1, -1)
$Food = GUICtrlCreateInput("", 24, 88, 225, 21)
$Marketmax = GUICtrlCreateLabel("Marketplace maximum", 24, 8, 109, 17)
$Marketplace = GUICtrlCreateInput("", 24, 32, 225, 21)
$Foodtext = GUICtrlCreateLabel("Food", 24, 64, 28, 17)
$Woodtext = GUICtrlCreateLabel("Wood", 24, 120, 33, 17)
$Wood = GUICtrlCreateInput("", 24, 144, 225, 21)
$Irontext = GUICtrlCreateLabel("Iron", 24, 176, 22, 17)
$Iron = GUICtrlCreateInput("", 24, 200, 225, 21)
$Stonetext = GUICtrlCreateLabel("Stone", 24, 232, 32, 17)
$Stone = GUICtrlCreateInput("", 24, 256, 225, 21)
$Silvertext = GUICtrlCreateLabel("Silver", 24, 288, 30, 17)
$Silver = GUICtrlCreateInput("", 24, 312, 225, 21)
$Start = GUICtrlCreateButton("Start", 24, 344, 89, 33)
$Exit = GUICtrlCreateButton("Exit", 152, 344, 89, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Exit
            Exit

        Case $Start
            start()

    EndSwitch
WEnd

Func start()
    MsgBox(64, 'YES', 'JIHAA')
;~                 for $1 = 1 to $Food / $Marketplace
;~                     MouseClickDrag("left",731,228,891,228,10)
;~                     sleep(2000)
;~                     MouseClick("left",1011,882)
;~                     sleep(2000)
;~ Next ;==>start
EndFunc   ;==>start