orc1111

help with Loop, if and pixelsearch

8 posts in this topic

Hi guys im new in autoit so be pacient with me pls.

my code:

HotKeySet ("{f1}", "myExit")
HotKeySet ("{f2}", "SetHuntArea")
HotKeySet ("{f3}", "Tg")
HotKeySet ("{f4}", "StartStop")


Global $gathering = false;
;Area de colheita
Global $x1 =628
Global $y1 =280
Global $x2 =746
Global $y2 =397
;Time to gather MS
Global $tg = 2700

   while(1)
   ;find a closer carrot
   $pix = PixelSearch($x1,$y1,$x2,$y2,0xE0C6A2,20)
   if not (@error) then
      ;move and click on carrot
      MouseClick("right", $pix[0], $pix[1],1,1)
      sleep($tg)
      $gathering = True

     
   EndIf
WEnd
         ;if not find search for a far carrot
         ;$pix = PixelSearch(359,114,1008,582,0xFBDDB4,3)
         ;while($gathering)

func myExit ()
   msgbox (0, "Ending", "bot stoped")
   Exit
EndFunc

func SetHuntArea()
   MsgBox(0,"Setting Hunting Area","Place your mouse to the Top Left cornor, and press SPACE to continue.")
   $mouse = MouseGetPos()
   $x1 = $mouse[0]
   $y1 = $mouse[1]

   MsgBox(0,"Setting Hunting Area","Place your mouse to the Bottom Right cornor, and press SPACE to continue.")
   $mouse = MouseGetPos()
   $x2 = $mouse[0]
   $y2 = $mouse[1]
EndFunc

The idea:

first: gathering the closer carrots with PixelSearch

(need to wait a determinate time who will become shorter along the levels, so i need to change every level the delay to gathering another stuff)

 

second: if i cant get the closer ones, i need to reach the far ones.

(need to click on them with left button and when he get in the range to closer ones stop and grab them, and again and again and again.)

 

what already work:  take the closer ones.

what dont work:  click on far carrots reach then and grab.

change the delay to grab another carrot easily.

 

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

You mention carrots and colheita (harvest) so I get the impression you try to automate a game.
Game automation of any kind is not permitted here. Please read the forum rules and you will understand why you do not get any help on this subject.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

yes it was, i dont have any idea in a pratical use for imagesearch and pixelsearch, im just trying to learning using in a fun way.

if you know a good pratical exercise pls let me know, i want to learn more about pixelsearch and imagesearch, and other basic stuffs.

all the pratical exercises with pixelearch who i found is with games or painting.

Share this post


Link to post
Share on other sites

Pixel- and ImageSearch are far from being basic. Most of the people never need to use this functions as those use cases allowed by the forum rules can be coded with other functions.
Look for a good real-life use case and start to code. If you have questions we will be happy to assist :)

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

i will wait for the response of others members, thank you.

Share this post


Link to post
Share on other sites

still waiting for a help, or alternative ways (and easy) to learn pixelseach or imagesearch. 

people who do not want to help please do not change the purpose of the topic, thank you!

And again, i want help and not a solution. trying to learn something here!

Share this post


Link to post
Share on other sites

@orc1111 as has been pointed out to you, we do not support game automation threads. The tired old "I'm just using this for learning" excuse won't get you very far. Please read the forum rules to which you were pointed.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.