Jump to content

help with Loop, if and pixelsearch


Recommended Posts

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.

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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 :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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!

Link to comment
Share on other sites

  • Moderators

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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