Jump to content

need some help with my code


 Share

Recommended Posts

Hi i need a bit of help with my code my script keeps running but does not do the last bit of code if u can see what is wrong can u plz help

#include <GUIConstants.au3>

$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)

GUICtrlCreateLabel('Enter your MTGO username', 10, 12)

$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)

GUICtrlCreateLabel('Enter your MTGO password', 10, 54)

$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)

$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)

$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $exitbtn

ExitLoop

Case $msg = $okbtn

$x = GUICtrlRead($input1)

$y = GUICtrlRead($input2)

GUISetState( @SW_HIDE, $myGUI)

MouseClick("left", 424, 356)

Send($x)

MouseClick("left", 434, 413)

Send($y)

MouseClick("left", 491, 444)

EndSelect

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum

$checksum = PixelChecksum(0,0,50,50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load

While $checksum = PixelChecksum(0,0,50,50)

Sleep(100)

WEnd

MsgBox(0, "", "Something in the region has changed!")

Link to comment
Share on other sites

You forgot a wEnd in the main while loop ... Also, put the code in a code box (The little A3 at the top of edit post window)

Hallman

EDIT: Cleaned it up a bit

#include <GUIConstants.au3>

$myGUI = GUICreate("Title", 320, 120)
GUICtrlCreateLabel('Enter your MTGO username', 10, 12)
$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)
GUICtrlCreateLabel('Enter your MTGO password', 10, 54)
$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)
$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)
$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $exitbtn Or $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $okbtn
            $x = GUICtrlRead($input1)
            $y = GUICtrlRead($input2)
            GUISetState(@SW_HIDE, $myGUI)
            MouseClick("left", 424, 356)
            Send($x)
            MouseClick("left", 434, 413)
            Send($y)
            MouseClick("left", 491, 444)
            
            ExitLoop
    EndSelect
WEnd

; Wait until something changes in the region 0,0 to 50,50
; Get initial checksum
$checksum = PixelChecksum(0, 0, 50, 50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $checksum = PixelChecksum(0, 0, 50, 50)
    Sleep(100)
WEnd

MsgBox(0, "", "Something in the region has changed!")
Edited by Hallman
Link to comment
Share on other sites

Hi i need a bit of help with my code my script keeps running but does not do the last bit of code if u can see what is wrong can u plz help

#include <GUIConstants.au3>

$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)

GUICtrlCreateLabel('Enter your MTGO username', 10, 12)

$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)

GUICtrlCreateLabel('Enter your MTGO password', 10, 54)

$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)

$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)

$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $exitbtn

ExitLoop

Case $msg = $okbtn

$x = GUICtrlRead($input1)

$y = GUICtrlRead($input2)

GUISetState( @SW_HIDE, $myGUI)

MouseClick("left", 424, 356)

Send($x)

MouseClick("left", 434, 413)

Send($y)

MouseClick("left", 491, 444)

EndSelect

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum

$checksum = PixelChecksum(0,0,50,50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load

While $checksum = PixelChecksum(0,0,50,50)

Sleep(100)

WEnd

MsgBox(0, "", "Something in the region has changed!")

not sure what your aiming for here. You are starting two while loops but only closing one. the loop for the get msg was never closed with WEnd. Do you know the name of the window your sending to? If so have your tried to send to the control of that window?

Link to comment
Share on other sites

HI,

Don't know what you expect from your code. But I do know that you would get some clues if you tidied it up. SciTe4Autoit has a nice tool to help you out. CTRL+T (tidy in the tools menu).

It would also help the rest of us if you used the AutoIt tag around your code when posting.

Now, does this code look right to you?

I think you will get stuck in the last while loop. :whistle: Or did the code crash and burn because you did not provide the closing WEnd?

#include <GUIConstants.au3>
$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)
GUICtrlCreateLabel('Enter your MTGO username', 10, 12)
$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)
GUICtrlCreateLabel('Enter your MTGO password', 10, 54)
$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)
$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)
$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $exitbtn
            ExitLoop
        Case $msg = $okbtn
            $x = GUICtrlRead($input1)
            $y = GUICtrlRead($input2)
            GUISetState(@SW_HIDE, $myGUI)
            MouseClick("left", 424, 356)
            Send($x)
            MouseClick("left", 434, 413)
            Send($y)
            MouseClick("left", 491, 444)
    EndSelect
    ; Wait until something changes in the region 0,0 to 50,50
    ; Get initial checksum
    $checksum = PixelChecksum(0, 0, 50, 50)

    ; Wait for the region to change, the region is checked every 100ms to reduce CPU load
    While $checksum = PixelChecksum(0, 0, 50, 50)
        Sleep(100)
    WEnd

    MsgBox(0, "", "Something in the region has changed!")

Happy bug hunting ;)

Link to comment
Share on other sites

so is this what u mean

WinActivate("Magic Online V2.0.066.1641")

#include <GUIConstants.au3>

$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)

GUICtrlCreateLabel('Enter your MTGO username', 10, 12)

$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)

GUICtrlCreateLabel('Enter your MTGO password', 10, 54)

$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)

$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)

$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $exitbtn

ExitLoop

Case $msg = $okbtn

$x = GUICtrlRead($input1)

$y = GUICtrlRead($input2)

GUISetState( @SW_HIDE, $myGUI)

MouseClick("left", 424, 356)

Send($x)

MouseClick("left", 434, 413)

Send($y)

MouseClick("left", 491, 444)

EndSelect

WEnd

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum

$checksum = PixelChecksum(0,0,50,50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load

While $checksum = PixelChecksum(0,0,50,50)

Sleep(100)

WEnd

MsgBox(0, "", "Something in the region has changed!")

i dont know how to do that code box thing :whistle:

Link to comment
Share on other sites

k i leraned how to do that now so is this right and the code still does not work :whistle:

WinActivate("Magic Online V2.0.066.1641")
#include <GUIConstants.au3>
$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)
GUICtrlCreateLabel('Enter your MTGO username', 10, 12)
$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)
GUICtrlCreateLabel('Enter your MTGO password', 10, 54)
$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)
$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)
$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $exitbtn
ExitLoop
Case $msg = $okbtn
$x = GUICtrlRead($input1)
$y = GUICtrlRead($input2)
GUISetState( @SW_HIDE, $myGUI)
MouseClick("left", 424, 356)
Send($x)
MouseClick("left", 434, 413)
Send($y)
MouseClick("left", 491, 444)
EndSelect
WEnd

; Wait until something changes in the region 0,0 to 50,50
; Get initial checksum
$checksum = PixelChecksum(0,0,50,50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $checksum = PixelChecksum(0,0,50,50)
Sleep(100)
WEnd

MsgBox(0, "", "Something in the region has changed!")
Link to comment
Share on other sites

Seems as if you are trying to have a dialog that will take a user id and pswd then send it to another window. If so doesn't seem like you need the GUI open anylonger and you can close it by exiting the first loop. I am not sure what your doing with the pixelchecksum. But it will only happen when you click the exit button.

Link to comment
Share on other sites

its a bot that im working on and i use the pixelchecksum so it will wait intill it has logged on but i cant use the sleep functon becouse it will sometimes lag and take more then must of the time to log on. but its not doing the checksum when i press ok

Link to comment
Share on other sites

I see.

It won't do the pixelchecksum with the ok button because the pixelchecksum is outside the gui loop. It won't do it until the gui closes. If you don't need the gui then include a exitloop for the okbtn case statement. That will exit the gui loop to preform other operations after pressing ok.

#include <GUIConstants.au3>
$myGUI = GUICreate(" My GUI input acceptfile", 320, 120)
GUICtrlCreateLabel('Enter your MTGO username', 10, 12)
$input1 = GUICtrlCreateInput("", 10, 30, 300, 20)
GUICtrlCreateLabel('Enter your MTGO password', 10, 54)
$input2 = GUICtrlCreateInput("", 10, 70, 300, 20, $ES_PASSWORD)
$okbtn = GUICtrlCreateButton("Ok", 40, 95, 60, 20)
$exitbtn = GUICtrlCreateButton("Exit", 120, 95, 60, 20)
GUISetState()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $exitbtn
            Exit
        Case $msg = $okbtn
            ;read the inputs then exit
            $x = GUICtrlRead($input1)
            $y = GUICtrlRead($input2)
            ExitLoop
    EndSelect
WEnd

GUIDelete()

MouseClick("left", 424, 356)
Send($x)
MouseClick("left", 434, 413)
Send($y)
MouseClick("left", 491, 444)

; Wait until something changes in the region 0,0 to 50,50
; Get initial checksum
$checksum = PixelChecksum(0, 0, 50, 50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $checksum = PixelChecksum(0, 0, 50, 50)
    Sleep(100)
WEnd

MsgBox(0, "", "Something in the region has changed!")

If the login is in a seperate window you can use a winwaitclose or winwaitnotactive to check when a login window is not active anymore as well. Or you could use a winwaitactive to see when a specific window becomes active.

If I'm wrong and you need the gui to remain active if you move the pixelchecksum statement up to inside the okbtn case statement it will then do them on pressing the OK.

Good luck

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...