2017-03-28 70 views
2

在我當前的GUI中,有一些按鈕一旦點擊就會出現其他GUI,提示用戶輸入信息以便繼續使用腳本。一旦按下按鈕,它就會像往常一樣工作,但是當您將任何信息放入彈出式GUI時,主GUI也會發生反應,這是不好的,因爲它是嵌入式IE瀏覽器,當它接收到用戶的輸入時,它把所有的東西都弄亂了。如何在Autoit中禁用主GUI

這是當前的代碼。

任何幫助將不勝感激!

#include <ButtonConstants.au3> 
#include <EditConstants.au3> 
#include <GUIConstantsEx.au3> 
#include <WindowsConstants.au3> 
#include <StaticConstants.au3> 
#include <ComboConstants.au3> 
#include <WinHttp.au3> 
#include <IE.au3> 
#include <GUIConstantsEx.au3> 
#include <GuiEdit.au3> 
#include <WinAPIFiles.au3> 
#include <ImageSearch2015.au3> 

Opt('SendKeyDelay', Random (16,80)); default 5. higher number = slower 
Global $nameInfo = IniRead('Userinfo.ini', 'Name', 'Name', 'No username on file') 
Global $passInfo = IniRead('Userinfo.ini', 'Pass', 'Pass', 'No password on file') 
Global $slpMed = Random (2000, 2500) 
Global $slpLow = Random (100, 350) 

;Not in use ATM, will be used in future builds. 
Global $en = '....' ;Need to find out how to login through world # 
Global $mainUrl = 'https://' & $en & '.******' 
Global $testUrl = 'https://*********' 

Main_GUI() 

Func Main_GUI() 
AutoItSetOption ("MouseCoordMode", 0) 
$EzTw = GUICreate("Ez Tw", 885, 513, -1, -1) 
GUISetBkColor(0xA0A0A0) 
$Username = GUICtrlCreateInput($nameInfo, 8, 32, 105, 21) 
GUICtrlSetBkColor(-1, 0xFFFFFF) 
$Password = GUICtrlCreateInput($passInfo, 120, 32, 105, 21) 
GUICtrlSetBkColor(-1, 0xFFFFFF) 
$LogBtn = GUICtrlCreateButton("Login", 24, 56, 75, 17) 
GUICtrlSetBkColor(-1, 0xFFFFFF) 
$UserT = GUICtrlCreateLabel("User name", 40, 8, 55, 17) 
$PassT = GUICtrlCreateLabel("Password", 144, 8, 50, 17) 
$SaveBtn = GUICtrlCreateButton("Save Info", 136, 56, 75, 17) 
GUICtrlSetBkColor(-1, 0xFFFFFF) 
$Group1 = GUICtrlCreateGroup("Group1", -16, -40, 257, 129) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$Group2 = GUICtrlCreateGroup("Group2", 240, -16, 265, 105) 
$btnAxeLc = GUICtrlCreateButton("Axe/LC", 248, 32, 75, 17) 
$btnLcHc = GUICtrlCreateButton("Lc/Hc", 248, 8, 75, 17) 
$btnSpHc = GUICtrlCreateButton("Sp/Hc", 248, 56, 75, 17) 
$btnSwAc = GUICtrlCreateButton("Sw/Ac", 336, 8, 75, 17) 
$btnAxe = GUICtrlCreateButton("Axe Only", 336, 32, 75, 17) 
$btnSpear = GUICtrlCreateButton("Spear Only", 336, 56, 75, 17) 
$btnArcher = GUICtrlCreateButton("Archer Only", 424, 8, 75, 17) 
$btnSword = GUICtrlCreateButton("Sword Only", 424, 32, 75, 17) 
$btnMounted = GUICtrlCreateButton("MA Only", 424, 56, 75, 17) 
Global $ie = _IECreateEmbedded() 
Global $inIW = GUICtrlCreateObj($ie, 10, 100, 865, 405) 
With $ie 
.navigate ("*******") 
EndWith 
GUISetState(@SW_SHOW) 

While 1 
    $nMsg = GUIGetMsg() 
    Switch $nMsg 
     Case $GUI_EVENT_CLOSE 
      Exit 
     Case $saveBtn 
      $User = GUICtrlRead($Username) 
      IniWrite("Userinfo.ini", "Name", "Name", $User) 
      $Pass = GUICtrlRead ($Password) 
      IniWrite("Userinfo.ini", "Pass", "Pass", $Pass) 
     Case $logBtn 
      $User = GUICtrlRead($Username) 
      $Pass = GUICtrlRead ($Password) 
      With $ie 
       While ($ie.busy) 
       WEnd 
       Sleep ($slpLow) 
       $txtUser = .document.getElementById('user') 
       $txtUser.value = $User 
       Sleep ($slpLow) 
       $txtPass = .document.getElementById('password') 
       $txtPass.value = $Pass 
       Sleep ($slpLow) 
      For $a In _IETagNameGetCollection($ie, "a") 
       If StringInStr(_IEPropertyGet($a, "innerText"), "Login") Then 
         $a.fireEvent("onmousedown") 
         sleep ($slpLow) 
         $a.fireEvent("onmouseup") 
         _IEAction($a, "click") 
       EndIf 
      Next 
      Sleep ($slpMed) 
       EndWith 

     Case $btnAxeLc 
       call ('AxeLcGUI') 



     Case $btnLcHc 

     Case $btnSpHc 

     Case $btnSwAc 

     Case $btnArcher 

     Case $btnAxe 

     Case $btnSpear 

     Case $btnSword 

     Case $btnMounted 

    EndSwitch 
WEnd 
EndFunc 

Func AxeLcGUI() 
$axeInfo = IniRead('Userinfo.ini', 'AxeLC', 'Axe', 'Not on file') 
$lcInfo = IniRead('Userinfo.ini', 'AxeLC', 'LC', 'Not on file') 
$LcForm = GUICreate("Axe/Lc", 315, 134, -1, -1) 
$AxNum = GUICtrlCreateInput($axeInfo, 32, 40, 73, 21) 
$AxNumT = GUICtrlCreateLabel("How Many Ax/run?", 24, 16, 96, 17) 
$LcNum = GUICtrlCreateInput($lcInfo, 176, 40, 73, 21) 
$LcNumT = GUICtrlCreateLabel("How many LC/run?", 168, 16, 96, 17) 
$LootAssist = GUICtrlCreateButton("Loot Assist", 32, 88, 75, 25) 
$btnSave = GUICtrlCreateButton("Save Info", 176, 88, 75, 25) 
GUISetState(@SW_SHOW) 
While 1 
    $nMsg = GUIGetMsg() 
    Switch $nMsg 
     Case $GUI_EVENT_CLOSE 
       GUIDelete(AxeLcGUI) 
       ExitLoop 

     Case $btnSave 
      Global $axeReal = GUICtrlRead($AxNum) 
      IniWrite("Userinfo.ini", "AxeLC", "Axe", $axeReal) 
      Global $lcReal = GUICtrlRead ($LcNum) 
      IniWrite("Userinfo.ini", "AxeLC", "LC", $lcReal) 

     Case $LootAssist 
      $axeReal = GUICtrlRead($AxNum) 
      $lcReal = GUICtrlRead($LcNum) 
      Call ("AxeLcFarm") 




    EndSwitch 
WEnd 
EndFunc 

Func AxeLCFarm() 
     With $ie 

       Local $oInputs = _IETagNameGetCollection($ie, "input") 
       For $oInput In $oInputs 
       If $oInput.name == "axe" Then 
        $oInput.value = $axeReal 
        EndIf 
       Next 
       Local $oInputs = _IETagNameGetCollection($ie, "input") 
       For $oInput In $oInputs 
       If $oInput.name == "light" Then 
        $oInput.value = $lcReal 
        EndIf 
       Next 
       EndWith 

EndFunc 

Func LootAssist() 
       With $ie 
       Local $oInputs = _IETagNameGetCollection($ie, "a") 
       For $oInput In $oInputs 
       If $oInput.title == "Loot Assistant" Then 
        $oInput.fireEvent("onmousedown") 
        sleep ($slpLow) 
        $oInput.fireEvent("onmouseup") 
        _IEAction($oInput, "click") 
        EndIf 
       Next 
       EndWith 
    EndFunc 

Func Farm() 
WinActivate ('001') 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
Sleep (100) 
send ('A') 
EndFunc 

Func Terminate() 
Exit 0 
EndFunc 

基本上,當我把輸入AxeLcGUI,它還影響到mainGUI,然後打破了代碼。

+0

修正了它。不使用圖形用戶界面,只需使用輸入框來收集信息就簡單高效,不必處理所有額外的頭部疼痛。 – James

回答

0

&hellip;當你將任何信息放入彈出式GUI時,主GUI也會發生反應......

作爲每documentation

當使用 「高級」 參數的信息與擴展信息的數組返回:

$aArray[0] = 0或事件ID或控制ID
$aArray[1] =窗口句柄事件是從
$aArray[2] =事件的控制句柄來自(如果適用)
$aArray[3] =鼠標光標的(相對於GUI窗口)
$aArray[4] =鼠標光標的(相對於GUI窗口)當前Y位置

GUIGetMsg($GUI_EVENT_ARRAY)使窗口的識別當前X位置從中消息來源。例如:

If $aArray[0] = $GUI_EVENT_CLOSE And $aArray[1] = $hGUI2 Then 

    ; Your code 

EndIf