Jump to content

PixelSearch: Wait until Pixel changes Color and after click on it - (Locked)


Recommended Posts

Hey,

 

I'm trying to create a script which will Move my Cursor to the color location found via PixelSearch: 0xFB9303

After that it should wait until the color changes to 0xFFCFC7

As soon as it changes to 0xFFCFC7 it should click on it as fast as possible 

I tryed a few things but could not figure out how to do that and get it working.

 

Thats my Code so far which is as it is right now only clicking on the Color it should click on, but sadly thats too slow: 

HotKeySet("g", "start")
HotKeySet("h", "stop")


While 1
    Sleep(100)
WEnd

func stop()
    Exit
EndFunc

func start()
    while 1

      $productbar1 = PixelSearch(850,750,1050,800, 0xFFCFC7,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 1)
         MouseClick("left", $productbar1[0], $productbar1[1]-5, 1, 0)
         EndIf
         Sleep(200)
    WEnd
EndFunc

thank you in advance and i hope i explained it well, sorry for my bad english.

Link to post
Share on other sites

This question, with slight variations, has been asked thousands of times. The default answer is : "Which application or website do you want to automate. There are almost always more reliable methods available than Pixelsearch." More details and also screenshots would be helpful for further assistance.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites

Well, i changed the code a bit: 

#RequireAdmin
HotKeySet("g", "start")
HotKeySet("h", "stop")

$WaitColor=0xFB9303
$ClickColor=0xFFCFC7

While 1
    Sleep(100)
WEnd

func stop()
    Exit
EndFunc

func start()
    while 1

      $productbar1 = PixelSearch(850,750,1050,800, $WaitColor,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 1)
      EndIf
      $productbar2 = PixelSearch(850,750,1050,800, $ClickColor,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 0)
         MouseClick("left", $productbar1[0], $productbar1[1]-5, 1, 0)
         Sleep(200)
      EndIf
    WEnd
EndFunc

and now it is working like it should but it crashes after a few seconds with the Crash Code 

 

Line 20 (File:"File Path, File Name")

Error: Subscript used on non-accessible variable

 

 

But Anyways, here are the informations you asked for:

oR01021.png

there is this little Bar with the blue thing going to the left and to the right side,

As soon as it hits the Yellow Thing, the color changes:

image.png.1487d1d88c8cb254641b00965c074037.png

Now what i want to do is to let the script move to the Yellow thing of the Screenshot above, as soon as it appears on the screen, but wait, and as soon as the color changes to the one of the screenshot below it should click on it. Its not really an automation its more like workflow optimization in my opinion.

Hope you understand what i'm talking about and can help me

 

Thanks.

 

Link to post
Share on other sites
  • Moderators

@holzrusse That looks an awful lot like you're trying to automate a game, am I correct?

 

                                                                                    ====In case you missed it, this is a Mod stepping into a thread====

"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 post
Share on other sites
Just now, JLogan3o13 said:

@holzrusse That looks an awful lot like you're trying to automate a game, am I correct?

As i said, i'm not looking for to automate a game, just a completion to make it a bit easier, but still nothing where  you can go afk or something "gamebreaking"

                                                                                    ====In case you missed it, this is a Mod stepping into a thread====

 

Link to post
Share on other sites
  • Developers
7 minutes ago, holzrusse said:

As i said, i'm not looking for to automate a game, just a completion to make it a bit easier, but still nothing where  you can go afk or something "gamebreaking"

So the answer is : Yes it is for a Game! right?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

Then things are simple:

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

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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