如何区分多个GUI?

时间:2017-03-28 01:56:55

标签: user-interface autoit

按下按钮后,我的GUI会显示其他GUI(正常工作)。

但是当我与弹出式GUI交互时,主GUI也会做出反应(嵌入式IE浏览器;当它接收到输入时,它会混淆一切)。这是代码:

#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()的输入也会转到主GUI,这是不受欢迎的。

1 个答案:

答案 0 :(得分:0)

  

...当您将任何信息放入弹出GUI时,主GUI也会做出反应......

根据documentation

  

使用&#34;高级&#34;参数信息以扩展信息的形式返回:

  $aArray[0] = 0或事件ID或控件ID
  $aArray[1] =事件的窗口句柄来自
  $aArray[2] =事件来自的控制手柄(如果适用)
  $aArray[3] =鼠标光标的当前X位置(相对于GUI窗口)
  $aArray[4] =鼠标光标的当前Y位置(相对于GUI窗口)

GUIGetMsg($GUI_EVENT_ARRAY)可以识别消息所来自的窗口。例如:

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

    ; Your code

EndIf