Jump to content

Loop while a certain color exists on the Search Area - (Locked)


Recommended Posts

Posted (edited)

So, as you would probably note from my code and such, I'm new to AutoIt coding, so there is probably a better way to code it, or a simple solution that I'm not seeing, so I'm trying to get better at it, and I appologize in advance. I made an example of what I'm trying to do, with my code and an image to better exemplify what I'm trying to achieve

 

I have a character that is performing an action (example here is the stickman attacking those green things)

Everytime he is engaged in that action, he moves to where the green enemy is. So I'm trying to make a script that keeps engaged in the action while the enemy is in front of him, and keeps on repeating this action of searching and clicking on them, while there are still green enemies to his left and right.

 

Simply, that is what I'm trying to achieve:

1. Searchs if the green enemy is in front of him

  -if it is, stay in the same position, untill it's not there anymore

    -if it's not, search for the green enemy to it's right and left, and click on it

 

For the sake of searching if it is in front of him and staying in there untill it disappears, I made a "MouseMove" that I thought was going to keep the mouse on top of this green enemy, while it was there. But it only moves over it once or twice, and then it clicks on the green enemies that are from it's left/right, even if the green enemy that is in front of him has not been killed, and that is not what I'm trying to achieve.

I know it is clicking away because the MouseClick function that is being triggered later in the other part the of the code, but I can't think of a way to not trigger it, while the green is still in front of the stickman.

So, here's the code I have and the image to ilustrate it better:

#include <AutoItConstants.au3>

HotKeySet("{esc}", "quit")

While(1)

for $count = 1 to 20

   ;search for the green color on the central piece - under the stickman
   $pixels1 = PixelSearch(390, 310, 430, 353, 0x31ff31, 1)
   if NOT(@error) Then
      MouseMove($pixels1[0], $pixels1[1])
      sleep (350)
   EndIf


     ;search for the green color to the left of the stickman
     $pixels2 = PixelSearch(120, 310, 375, 353, 0x31ff31, 1)
     
     if NOT(@error) Then
        MouseClick($MOUSE_CLICK_LEFT, $pixels2[0], $pixels2[1])
        sleep (1* 2500)
     EndIf


       ;search for the green color to the right of the stickman
       $pixels3 = PixelSearch(445, 310, 698, 353, 0x31ff31, 1)
       
       if NOT(@error) Then
          MouseClick($MOUSE_CLICK_LEFT, $pixels3[0], $pixels3[1])
          sleep (1* 3500)
       EndIf

Next
WEnd

Func quit()
    Exit
EndFunc   ;==>quit

If anyone could help me here, I would be very thankful!

a1.png

Edited by iTzSublime
Link to post
Share on other sites
  • Moderators

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...