Sign in to follow this  
Followers 0
Second

help on loop

9 posts in this topic

#1 ·  Posted (edited)

ok i found a solution

cheers!

Edited by second

Share this post


Link to post
Share on other sites



@second

Global $Paused
#include <GUIConstants.au3>
Opt("trayiconhide", 1)
HotKeySet("{F1}", "bot")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F2}", "standby")
$GUI = GUICreate("Bot trial", 190, 230, -1, -1)
$Label_1 = GUICtrlCreateLabel("Type colour code:", 10, 10, 130, 15)
$Input_1 = GUICtrlCreateInput("11437410", 10, 30, 100, 20)
$start = GUICtrlCreateButton("start bot", 10, 61, 90, 30)
$stop = GUICtrlCreateButton("stop bot", 100, 61, 90, 30)
$Credits = GUICtrlCreateLabel("Credits:" & @CRLF & "Second", 130, 2)
$Label_2 = GUICtrlCreateLabel("Shade variaty", 10, 95, 170, 30)
$Input_2 = GUICtrlCreateInput("", 10, 110, 100, 23)
GUISetState(@SW_SHOW)
$nMsg = GUIGetMsg()
$colour = GUICtrlRead($Input_1)
$shade = GUICtrlRead($Input_2)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit 0 Or Call("Terminate")
        Case $nMsg = $start
            Call("bot")
        Case $nMsg = $stop
            Call("standby")
    EndSelect
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func standby()
    While 2
        Sleep(1000)
    WEnd
EndFunc   ;==>standby



Func bot()
    While 1

        $k = MouseGetPos()
        $pos = PixelSearch($k[0] - 250, $k[1] - 250, $k[0] + 250, $k[1] + 350, $colour, $shade)
        If Not @error Then
            MouseMove($pos[0], $pos[1])
            MouseClick("left")
            Sleep(100)
            MouseMove(303, 409)
            Sleep(6000)
        Else
            MsgBox(64, "error", "failed to find the provided pixel retry in 1 sec", 1)
            Sleep(1000)
        EndIf
    WEnd
EndFunc   ;==>bot

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

bump! i need to end a loop in func by pressing gui button-$stop, any ideas?

You can

Use a hotkey

OR

Check for the button press with another $msg = GuiGetMsg() section in your loop

OR

use OnEvent mode to get out of it by pressing a button.

The function must not be called by an event.

The event called by the button can set a global variable which is tested in the loop in the function. You could have something like

If $endlopp then return.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Second

Maybe...

#include <GUIConstants.au3>

#NoTrayIcon
global $endloop=1

HotKeySet("{F1}", "bot")
HotKeySet("{ESC}", "_Terminate")
HotKeySet("{F2}", "_standby")

$GUI = GUICreate("Rs bot", 190, 230, -1, -1)
$Label_1 = GUICtrlCreateLabel("Type colour code:",10, 10, 130, 15)
$Input_1 = GUICtrlCreateInput("11437410", 10, 30, 100, 20)
$start = GUICtrlCreateButton("start bot", 10, 61, 90, 30)
$stop = GUICtrlCreateButton("stop bot", 100, 61, 90, 30)
$Credits = GUICtrlCreateLabel("Credits:" & @CRLF & "Seltas", 130, 2)
$Label_2 = GUICtrlCreateLabel("Shade variaty", 10, 95, 170, 30)
$Input_2 = GUICtrlCreateInput("", 10, 110, 100, 23)
$coins = GUICtrlCreateCheckbox("Pickup coins?",10, 150)

$nMsg = GUIGetMsg()
$colour=GUICtrlRead($Input_1)
$shade=GUICtrlRead($Input_2)
GUISetState(@SW_SHOW)
while 1
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
case $nMsg=$start
bot()
case $nMsg = $stop
send("{F2}")
endselect
wend

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate, exits scirpt

Func _standby()
    Global $endloop = 0
EndFunc   ;==>_standby ends the bot() func


Func bot();=====the main bot script
  Global $endloop=1
  While 1
$nmsg = GuiGetMsg()
Select
Case $nmsg = $stop
Global $endloop=0
ExitLoop
EndSelect    
    If $endloop=0 then exitloop
          $k = MouseGetPos()
          $pos = PixelSearch($k[0] - 250, $k[1] - 250, $k[0] + 250, $k[1] + 250, $colour, $shade)
          If Not @error Then
            MouseMove($pos[0], $pos[1])
            MouseClick("left")
            Sleep(100)
            MouseMove(303, 409)
            Sleep(6000)
          Else
            MsgBox(64, "error", "failed to find "&$colour&", retry in 1 sec", 1)
            Sleep(1000)
          endif
  wend
        endfunc

Cheers, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Im almost done with this example bot i want to post but can't find a way to get GUI to work in funcs' loop, tried looping func in select case but failed...

Any suggestions?

edit: sorry, I wasn't aware of that

Second

Edited by second

Share this post


Link to post
Share on other sites

@second

Your 'game' should stop now or I will advert mod

Reason : Deleting last reply and rewriting almost same thing for bump his topic (today min 3times)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

bump

edit: ok I'll look into that tomorow, need to sleep

Edited by second

Share this post


Link to post
Share on other sites

Case $nMsg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

anyone know how to sort this problem? :\

Share this post


Link to post
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
Sign in to follow this  
Followers 0