Jump to content

Do something untill a button is hit to stop the action.


Assault
 Share

Recommended Posts

I want to have the script click in a certain spot over and over(not at a very fast speed so they can use the mouse) until a button on the GUI is pressed, I dont know how I would go about doing this but what I have tried hasn't worked. : /

Soooo... here is what I last tried.

$Slots = GUICreate("Moo", 134, 74, 193, 125, BitOR($WS_SYSMENU,$WS_POPUP,$WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW)
$Label1 = GUICtrlCreateLabel("Click Delay", 16, 4, 57, 17)
$start = GUICtrlCreateButton("Start", 18, 46, 36, 20, 0)
$Input1 = GUICtrlCreateInput("In seconds", 15, 22, 97, 21)
$stop = GUICtrlCreateButton("Stop", 65, 46, 39, 20, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $start
            do
            mouseclick("left",511,422,1)
            sleep(1000)
            $count += 1
                if $count = 5 Then
                    WinActivate("")
                    sleep(100)
                    WinMove("","",1,1)
                    $count = 0
                EndIf
            until case $stop ;;;;;;;this right here cant work...
        case $stop
                
    EndSwitch
WEnd
Link to comment
Share on other sites

$Slots = GUICreate("Moo", 134, 74, 193, 125, BitOR($WS_SYSMENU,$WS_POPUP,$WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW)
$Label1 = GUICtrlCreateLabel("Click Delay", 16, 4, 57, 17)
$start = GUICtrlCreateButton("Start", 18, 46, 36, 20, 0)
$Input1 = GUICtrlCreateInput("In seconds", 15, 22, 97, 21)
$stop = GUICtrlCreateButton("Stop", 65, 46, 39, 20, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $start
            do
            mouseclick("left",511,422,1)
            sleep(1000)
            $count += 1
                if $count = 5 Then
                    WinActivate("")
                    sleep(100)
                    WinMove("","",1,1)
                    $count = 0
                EndIf
            Until $nMsg =  $stop ; Maybe?
    EndSwitch
WEnd

Try the code now... :D

Link to comment
Share on other sites

$Slots = GUICreate("Moo", 134, 74, 193, 125, BitOR($WS_SYSMENU,$WS_POPUP,$WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW)
$Label1 = GUICtrlCreateLabel("Click Delay", 16, 4, 57, 17)
$start = GUICtrlCreateButton("Start", 18, 46, 36, 20, 0)
$Input1 = GUICtrlCreateInput("In seconds", 15, 22, 97, 21)
$stop = GUICtrlCreateButton("Stop", 65, 46, 39, 20, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $start
            Do
            $msg = GUIGetMsg ()
            mouseclick("left",511,422,1)
            sleep(1000)
            $count += 1
                if $count = 5 Then
                    WinActivate("")
                    sleep(100)
                    WinMove("","",1,1)
                    $count = 0
                EndIf
            Until $msg =  $stop; Maybe?
    EndSwitch
WEnd

Edited by Bert
Link to comment
Share on other sites

$Slots = GUICreate("Moo", 134, 74, 193, 125, BitOR($WS_SYSMENU,$WS_POPUP,$WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW)
$Label1 = GUICtrlCreateLabel("Click Delay", 16, 4, 57, 17)
$start = GUICtrlCreateButton("Start", 18, 46, 36, 20, 0)
$Input1 = GUICtrlCreateInput("In seconds", 15, 22, 97, 21)
$stop = GUICtrlCreateButton("Stop", 65, 46, 39, 20, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $start
            Do
            $msg = GUIGetMsg ()
            mouseclick("left",511,422,1)
            sleep(1000)
            $count += 1
                if $count = 5 Then
                    WinActivate("")
                    sleep(100)
                    WinMove("","",1,1)
                    $count = 0
                EndIf
            Until $msg =  $stop; Maybe?
    EndSwitch
WEnd
Ohhh !!!!!!!!! You fast. I was just going to post that. :D

Edit It st should have worked just by changing the Until line too.

Until GUIGetMsg() = $Stop

And actually all of this might not work as expected because of the sleep in the loop. AutoIt wont read the GUI message while it's in the Sleep()

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Ohhh !!!!!!!!! You fast. I was just going to post that. :D

Fraid all aussies are fast like this... :P But not in the bedroom. Nahh mate. We take a veryyy long time. ;)

I just noticed he did declare it, I missed it before but yeah now I see it and it works.

lol.

11th Commandment: Read before thy posts.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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