2017-09-02 11 views
-1

GUIを実行しようとしました。私はGUIを起動できません。それは開きますが、ケース$Startは実行されません。GUIを起動する

#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 
      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 

答えて

0

GUISetOnEventを使用できます。 Hereは説明と例です。あなたのケースでは

#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 
+0

ニース。私は質問を変更したので、今度はすべてのコードがそこにあります。 コードにはスタートボタンがありますが、自分のコードを実装することはできません。 – Lazybutcrazy

+0

それぞれの 'case'ステートメントから関数を作るだけです。私の答えを見てください。 – matrix

+0

また、Start機能で問題が発生する可能性があります。Inputの内容を使用する場合は、GUICtrlReadで読み込む必要があります。次に例を示します。$ Food_val = GuiCtrlRead($ Food)。また、Start関数で$ Food_valを使用します。 – matrix

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 
関連する問題