Jump to content
Sign in to follow this  
baphomet

Looping problem

Recommended Posts

First time post :lmao:

I am trying to write a bot that will

Target a pixel

Double check within a small range from the first pixel

Check a health bar

etc

Its suppose to loop, but it doesnt seem to.

My error log seems to show its stops at veiw change

or if it finds a target before the health check.

I am at this point a little over my head, this is only my 3rd day messing with autoit and I am a little stuck.

Any one see anything wrong with this code that would stop it from looping, or anything else o:)

Thanks so much guys and gals

; AutoIt Version: 3.0
; Last modified:  1/22/2005
; Script Version: 6
; Language:    English
; Platform:    Win2k
; Author:        Chuck D.
; Script Function:
;   AutoBloom,  attack bot.

SplashTextOn("AutoBloom Version 6.0", "AutoBloom bot", 200, 20, -1, -1, 0, "", 10)
  Sleep(3000)
SplashOff()

MsgBox(48,"AutoBloom Version Beta 6.0","Press PAUSE to exit the script at any time" & @CRLF & "ALT-TAB  after 

clicking OK.")

HotKeySet("{PAUSE}", "EndScript")

$pixelColor = 14055713; Grunter Day
$pixelColor2 = 16754291; Health
$pixelColor3 = 15667200; monster health

$x = 0
$y = 0

$file = FileOpen("output.txt", 1)
FileWrite($file, "" & @CRLF)
FileWrite($file, "SCRIPT STARTED" & @CRLF)
FileWrite($file, "==============" & @CRLF)
FileWrite($file, "" & @CRLF)
FileClose($file)

Do
;MONSTER TARGET
$file = FileOpen("output.txt", 1)
  $mon = PixelSearch(195, 150, 850, 500, $Pixelcolor, 10)
    If Not @error Then
      FileWrite($file, "PixelCheck one Found" & @CRLF)
      MouseClick("left", $mon[0], $mon[1], 5)
      $y = $y + 1
    Else
      FileWrite($file, "Sending f1" & @CRLF)
      FileWrite($file, "No target" & @CRLF)
      Send("{F1}")
      MouseMove(526, 406)
      $pos = MouseGetPos()
      FileWrite($file, "View changed" & @CRLF)
      MouseClickDrag("right", $pos[0], $pos[1], $pos[0] +100, $pos[1])
      Sleep(2000)
      MouseClick("left", 511, 478, 5)
    EndIf
Wend

;MONSTER HEALTH CHECK
While $y = 1

$iX1 = $mon[0] - 100
$iY1 = $mon[1] - 100
$iX2 = $mon[0] + 100
$iY2 = $mon[1] + 100


  $aiCoord3 = PIXELSEARCH ($iX1, $iY1, $iX2, $iY2, $Pixelcolor3, 5)
    If Not @error Then
      Mousemove($aiCoord3[0], $aiCoord3[1], 5)
      FileWrite($file, "Monster Targeted" & @CRLF)
      $y = $y + 1
    Else
      MouseClick("left", 510, 528, 5)
      FileWrite($file, "PixelCheck two failed" & @CRLF)
      $y = $y - 1
  EndIf
Wend

;PLAYER HEALTH CHECK
While $y = 2
  $mon2 = PixelSearch( 128, 35, 150, 50, $Pixelcolor2 ) 
    If Not @error Then
      FileWrite($file, "Waiting 25 seconds" & @CRLF)
      Sleep(25000)
      FileWrite($file, "Sending F7" & @CRLF)
      Send("{F7}")
      FileWrite($file, "Sending f1" & @CRLF)
      Send("{F1}")
      FileWrite($file, "Health is fine" & @CRLF)
      $y = $y - 2
   
    Else
      FileWrite($file, "Sending f5" & @CRLF)
      Send("{F5}")
      FileWrite($file, "Waiting 25 seconds" & @CRLF)
      Sleep(25000)
      FileWrite($file, "Health is low" & @CRLF)
      $y = $y - 2
    EndIf
FileClose($file)
Wend

Until $X = 5

Func EndScript()
      
  Exit
EndFunc

Share this post


Link to post
Share on other sites

See MANUAL:

Do...Until not Do..Wend

First time post :lmao:

I am trying to write a bot that will

Target a pixel

Double check within a small range from the first pixel

Check a health bar

etc

Its suppose to loop, but it doesnt seem to.

My error log seems to show its stops at veiw change

or if it finds a target before the health check.

I am at this point a little over my head,  this is only my 3rd day messing with autoit and I am a little stuck.

Any one see anything wrong with this code that would stop it from looping, or anything else o:)

Thanks so much guys and gals

Do
;MONSTER TARGET
$file = FileOpen("output.txt", 1)
  $mon = PixelSearch(195, 150, 850, 500, $Pixelcolor, 10)
    If Not @error Then
      FileWrite($file, "PixelCheck one Found" & @CRLF)
      MouseClick("left", $mon[0], $mon[1], 5)
      $y = $y + 1
    Else
      FileWrite($file, "Sending f1" & @CRLF)
      FileWrite($file, "No target" & @CRLF)
      Send("{F1}")
      MouseMove(526, 406)
      $pos = MouseGetPos()
      FileWrite($file, "View changed" & @CRLF)
      MouseClickDrag("right", $pos[0], $pos[1], $pos[0] +100, $pos[1])
      Sleep(2000)
      MouseClick("left", 511, 478, 5)
    EndIf
Wend

<{POST_SNAPBACK}>

Edited by closeupman

Share this post


Link to post
Share on other sites

See MANUAL:

Do...Until  not Do..Wend

<{POST_SNAPBACK}>

Sorry no I mistakenly missed a line when copying to here.

I have While $y = 0

; AutoIt Version: 3.0
; Last modified:  1/22/2005
; Script Version: 6
; Language:    English
; Platform:    Win2k
; Author:        Chuck D.
; Script Function:
;   AutoBloom, Rose online attack bot.

SplashTextOn("AutoBloom Version 6.0", "AutoBloom bot for Rose Online", 200, 20, -1, -1, 0, "", 10)
  Sleep(3000)
SplashOff()


MsgBox(48,"AutoBloom Version Beta 6.0","Press PAUSE to exit the script at any time" & @CRLF & "ALT-TAB into Rose Online after 

clicking OK.")

HotKeySet("{PAUSE}", "EndScript")

$pixelColor = 14055713; Grunter Day
$pixelColor2 = 16754291; Health
$pixelColor3 = 15667200; monster health
;$pixelColor = 7046854; Grunter Night
;$pixelColor = 10252610; mine moldy
;$pixelColor = 16249715; moldy 

$x = 0
$y = 0

$file = FileOpen("output.txt", 1)
FileWrite($file, "" & @CRLF)
FileWrite($file, "SCRIPT STARTED" & @CRLF)
FileWrite($file, "==============" & @CRLF)
FileWrite($file, "" & @CRLF)
FileClose($file)

Do

;MONSTER TARGET
While $y = 0
$file = FileOpen("output.txt", 1)
  $mon = PixelSearch(195, 150, 850, 500, $Pixelcolor, 10)
    If Not @error Then
      FileWrite($file, "PixelCheck one Found" & @CRLF)
      MouseClick("left", $mon[0], $mon[1], 5)
      $y = $y + 1
    Else
      FileWrite($file, "Sending f1" & @CRLF)
      FileWrite($file, "No target" & @CRLF)
      Send("{F1}")
      MouseMove(526, 406)
      $pos = MouseGetPos()
      FileWrite($file, "View changed" & @CRLF)
      MouseClickDrag("right", $pos[0], $pos[1], $pos[0] +100, $pos[1])
      MouseClick("left", 511, 478, 5)
    EndIf
Wend

;MONSTER HEALTH CHECK
While $y = 1

$iX1 = $mon[0] - 100
$iY1 = $mon[1] - 100
$iX2 = $mon[0] + 100
$iY2 = $mon[1] + 100


  $aiCoord3 = PIXELSEARCH ($iX1, $iY1, $iX2, $iY2, $Pixelcolor3, 5)
    If Not @error Then
      Mousemove($aiCoord3[0], $aiCoord3[1], 5)
      FileWrite($file, "Monster Targeted" & @CRLF)
      $y = $y + 1
    Else
      MouseMove(526, 406)
      $pos = MouseGetPos()
      FileWrite($file, "View changed" & @CRLF)
      MouseClickDrag("right", $pos[0], $pos[1], $pos[0] +100, $pos[1])
      MouseClick("left", 511, 478, 5)
      FileWrite($file, "PixelCheck two failed" & @CRLF)
      $y = $y - 1
  EndIf
Wend

;PLAYER HEALTH CHECK
While $y = 2
  $mon2 = PixelSearch( 128, 35, 150, 50, $Pixelcolor2 ) 
    If Not @error Then
      FileWrite($file, "Waiting 25 seconds" & @CRLF)
      Sleep(25000)
      FileWrite($file, "Sending F7" & @CRLF)
      Send("{F7}")
      FileWrite($file, "Sending f1" & @CRLF)
      Send("{F1}")
      FileWrite($file, "Health is fine" & @CRLF)
      $y = $y - 2
    Else
      FileWrite($file, "Sending f5" & @CRLF)
      Send("{F5}")
      FileWrite($file, "Waiting 25 seconds" & @CRLF)
      Sleep(25000)
      FileWrite($file, "Health is low" & @CRLF)
      $y = $y - 2
    EndIf

Wend

Until $x = 1

Func EndScript()
      
  Exit
EndFunc
Edited by baphomet

Share this post


Link to post
Share on other sites

Get scite and load your scripts into the tidy program... Helps when reading and writing.


Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

Get scite and load your scripts into the tidy program... Helps when reading and writing.

<{POST_SNAPBACK}>

With tidy, the problem seems to be in my first pixel search, if I set it to say 0 - the numbers it will loop through the drag but these numbers it will just wait. (The commented line in monster target shows what will allow it to loop.

)

; <AUT2EXE VERSION: 3.0.102.0>

; ----------------------------------------------------------------------------
; <AUT2EXE INCLUDE-START: C:\-=FTP=-\-=UPLOADS=-\AutoBloom\Source\AutoBloom3.txt>
; ----------------------------------------------------------------------------

; AutoIt Version: 3.0
; Last modified:  1/22/2005
; Script Version: 6
; Language:    English
; Platform:    Win2k
; Author:        Chuck D.
; Script Function:
;   AutoBloom, Rose online attack bot.

SplashTextOn("AutoBloom Version 6.0", "AutoBloom bot for Rose Online", 200, 20, -1, -1, 0, "", 10)
Sleep(3000)
SplashOff()


MsgBox(48, "AutoBloom Version Beta 6.0", "Press PAUSE to exit the script at any time" & @CRLF & "ALT-TAB into Rose Online after clicking OK.")

HotKeySet("{PAUSE}", "EndScript")

$pixelColor = 14055713; Grunter Day
$pixelColor2 = 16754291; Health
$pixelColor3 = 15667200; monster health
$x = 0
$y = 0

$file = FileOpen("output.txt", 1)
FileWrite($file, "" & @CRLF)
FileWrite($file, "SCRIPT STARTED" & @CRLF)
FileWrite($file, "==============" & @CRLF)
FileWrite($file, "" & @CRLF)
FileClose($file)

Do
 ;MONSTER TARGET
   Sleep(2000)
   While $y = 0
      $file = FileOpen("output.txt", 1)
      $mon = PixelSearch(200, 150, 850, 500, $pixelColor, 10)
    ; $mon = PixelSearch(0-200, 0- 150, 0-850, 0-500, $pixelColor, 10)
      If Not @error Then
         FileWrite($file, "PixelCheck one Found" & @CRLF)
         MouseClick("left", $mon[0], $mon[1], 5)
         $y = $y + 1
      Else
         FileWrite($file, "Sending f1" & @CRLF)
         FileWrite($file, "No target" & @CRLF)
         Send("{F1}")
         MouseMove(526, 406)
         $pos = MouseGetPos()
         FileWrite($file, "View changed" & @CRLF)
         MouseClickDrag("right", $pos[0], $pos[1], $pos[0] + 100, $pos[1])
         MouseClick("left", 511, 478, 5)
         Sleep(5000)
      EndIf
   Wend
   
 ;MONSTER HEALTH CHECK
   While $y = 1
      
      $iX1 = $mon[0] - 100
      $iY1 = $mon[1] - 100
      $iX2 = $mon[0] + 100
      $iY2 = $mon[1] + 100
      
      
      $aiCoord3 = PixelSearch($iX1, $iY1, $iX2, $iY2, $pixelColor3, 5)
      If Not @error Then
         MouseMove($aiCoord3[0], $aiCoord3[1], 5)
         FileWrite($file, "Monster Targeted" & @CRLF)
         $y = $y + 1
      Else
         MouseMove(526, 406)
         $pos = MouseGetPos()
         FileWrite($file, "View changed" & @CRLF)
         MouseClickDrag("right", $pos[0], $pos[1], $pos[0] + 100, $pos[1])
         MouseClick("left", 511, 478, 5)
         FileWrite($file, "PixelCheck two failed" & @CRLF)
         $y = $y - 1
      EndIf
   Wend
   
 ;PLAYER HEALTH CHECK
   While $y = 2
      $mon2 = PixelSearch(128, 35, 150, 50, $pixelColor2)
      If Not @error Then
         FileWrite($file, "Waiting 25 seconds" & @CRLF)
         Sleep(25000)
         FileWrite($file, "Sending F7" & @CRLF)
         Send("{F7}")
         FileWrite($file, "Sending f1" & @CRLF)
         Send("{F1}")
         FileWrite($file, "Health is fine" & @CRLF)
         $y = $y - 2
      Else
         FileWrite($file, "Sending f5" & @CRLF)
         Send("{F5}")
         FileWrite($file, "Waiting 25 seconds" & @CRLF)
         Sleep(25000)
         FileWrite($file, "Health is low" & @CRLF)
         $y = $y - 2
      EndIf
      
   Wend
   
Until $x = 1

Func EndScript()
   Exit
EndFunc ;==>EndScript

; ----------------------------------------------------------------------------
; <AUT2EXE INCLUDE-END: C:\-=FTP=-\-=UPLOADS=-\AutoBloom\Source\AutoBloom3.txt>
; ----------------------------------------------------------------------------
Edited by baphomet

Share this post


Link to post
Share on other sites

I changed the script up a little, it seems to stop looping at the second pixelsearch in monster target. This is what my log shows it does:

SCRIPT STARTED
==============

;MONSTER TARGET
;error check is at 1
MONSTER TARGET: Else: Monster target check 1 failed
MONSTER TARGET: Else: Sending f1
MONSTER TARGET: Else: Wating 5 seconds until next action
MONSTER TARGET: Else: Camera rotated
MONSTER TARGET: Else: Moved a few steps
MONSTER TARGET: Else: Y is now at 0
;MONSTER TARGET

Here is the new code, any insite to why the script stops looping would be great this has me at a standstill.

<AUT2EXE VERSION: 3.0.102.0>
; ----------------------------------------------------------------------------
; <AUT2EXE INCLUDE-START: C:\-=FTP=-\-=UPLOADS=-\AutoBloom\Source\AutoBloom3.txt>
; ----------------------------------------------------------------------------
 
; AutoIt Version: 3.0
; Last modified:  1/22/2005
; Script Version: 6
; Language:    English
; Platform:    Win2k
; Author:        Chuck D.
; Script Function:
;   AutoBloom, Rose online attack bot.
 
 SplashTextOn("AutoBloom Version 6.0", "AutoBloom bot for Rose Online", 200, 20, -1, -1, 0, "", 10)
 Sleep(3000)
 SplashOff()
 
 
 MsgBox(48, "AutoBloom Version Beta 6.0", "Press PAUSE to exit the script at any time" & @CRLF & "ALT-TAB into Rose Online after clicking OK.")
 
 HotKeySet("{PAUSE}", "EndScript")
 WinActivate("ROSE online")
 Sleep(2000)
 
 $pixelColor = 14582305; Grunter Color: Day
 $pixelColor2 = 16736553; Player Health
 $pixelColor3 = 15674401; Monster Health
 
 $attacksleep = 3000
 
; DEBUG FILE - File must be created in exe directory
 $file = FileOpen("output.txt", 1)
 FileWrite($file, "" & @CRLF)
 FileWrite($file, "SCRIPT STARTED" & @CRLF)
 FileWrite($file, "==============" & @CRLF)
 FileWrite($file, "" & @CRLF)
 FileClose($file)
 
 $y = 0
 $loop = 0
 $errorcheck1 = 0
 While 1
   ;MONSTER TARGET
    While $y = 0
      If Not @error Then
         $file = FileOpen("output.txt", 1)
         FileWrite($file, ";MONSTER TARGET" & @CRLF)
         $mon = PixelSearch(20, 130, 850, 500, $pixelColor)
         If Not @error Then
            MouseClick("left", $mon[0], $mon[1], 0)
            FileWrite($file, "MONSTER TARGET: Not @error: Monster target check 1 succeeded" & @CRLF)
            $y = $y + 1
            FileWrite($file, "MONSTER TARGET: Not @error: Y is now at " & $y & @CRLF)
         Else
            $errorcheck1 = $errorcheck1 + 1
            FileWrite($file, ";error check is at " & $errorcheck1 & @CRLF)
            FileWrite($file, "MONSTER TARGET: Else: Monster target check 1 failed" & @CRLF)
            Send("{F1}")
            FileWrite($file, "MONSTER TARGET: Else: Sending f1" & @CRLF)
            Sleep(5000)
            FileWrite($file, "MONSTER TARGET: Else: Wating 5 seconds until next action" & @CRLF)
            MouseMove(500, 300)
            $pos = MouseGetPos()
            MouseClickDrag("right", $pos[0], $pos[1], $pos[0] + 100, $pos[1])
            FileWrite($file, "MONSTER TARGET: Else: Camera rotated" & @CRLF)
            MouseClick("left", 555, 444)
            FileWrite($file, "MONSTER TARGET: Else: Moved a few steps" & @CRLF)
            FileWrite($file, "MONSTER TARGET: Else: Y is now at " & $y & @CRLF)
         EndIf
      EndIf
    Wend
    
   ;MONSTER HEALTH CHECK
    While $y = 1
      If Not @error Then
         FileWrite($file, ";MONSTER HEALTH CHECK" & @CRLF)
         $iX1 = $mon[0] - 50
         $iY1 = $mon[1] - 50
         $iX2 = $mon[0] + 50
         $iY2 = $mon[1] + 50
         
         
         $aiCoord3 = PixelSearch($iX1, $iY1, $iX2, $iY2, $pixelColor3)
         If Not @error Then
            MouseMove($aiCoord3[0], $aiCoord3[1], 0)
            FileWrite($file, "MONSTER HEALTH CHECK: Not @error: Monster target check 2 succeeded" & @CRLF)
            $y = $y + 1
            FileWrite($file, "MONSTER HEALTH CHECK: Not @error: Y is now at " & $y & @CRLF)
         Else
            MouseMove(500, 580, 0)
            $pos = MouseGetPos()
            MouseClick("left", 500, 580, 5)
            FileWrite($file, "MONSTER HEALTH CHECK: Else: Monster target check 2 failed" & @CRLF)
            $y = $y + 1
            FileWrite($file, "MONSTER HEALTH CHECK: Else: Y is now at " & $y & @CRLF)
         EndIf
      EndIf
    Wend
    
   ;PLAYER HEALTH CHECK
    While $y = 2
      If Not @error Then
         FileWrite($file, "PLAYER HEALTH CHECK" & @CRLF)
         $mon2 = PixelSearch(133, 37, 178, 47, $pixelColor2)
         If Not @error Then
            FileWrite($file, "PLAYER HEALTH CHECK: Not @error: Player health is fine" & @CRLF)
            Sleep($attacksleep)
            FileWrite($file, "PLAYER HEALTH CHECK: Not @error: Waiting until next action" & @CRLF)
            Send("{F7}")
            FileWrite($file, "PLAYER HEALTH CHECK: Not @error: Sending f7" & @CRLF)
            Send("{F1}")
            FileWrite($file, "PLAYER HEALTH CHECK: Not @error: Sending f1" & @CRLF)
            $y = $y - 2
            FileWrite($file, "PLAYER HEALTH CHECK: Not @error: Y is now at " & $y & @CRLF)
         Else
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Player health is low" & @CRLF)
            Send("{F5}")
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Sending f5" & @CRLF)
            Sleep($attacksleep)
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Waiting until next action" & @CRLF)
            Send("{F7}")
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Sending f7" & @CRLF)
            Send("{F1}")
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Sending f1" & @CRLF)
            $y = $y - 2
            FileWrite($file, "PLAYER HEALTH CHECK: Else: Y is now at " & $y & @CRLF)
         EndIf
      EndIf
    Wend
    
 Wend
 
 Func EndScript()
    Exit
 EndFunc  ;==>EndScript
 
; ----------------------------------------------------------------------------
; <AUT2EXE INCLUDE-END: C:\-=FTP=-\-=UPLOADS=-\AutoBloom\Source\AutoBloom3.txt>
; ----------------------------------------------------------------------------

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...