Jump to content
Sign in to follow this  
SweatyOgre

A pretty simple problem

Recommended Posts

SweatyOgre

I need my script to look for a certain pixel in a given area, then if it finds the pixel, right click it. Here's my code, but it's not working.

$color = PixelSearch(430, 340, 710, 455, 6824048)
  If not @error then
     MouseClick("right",$color[0],$color[1], 1, 0)
  Else
  
  EndIf

If anyone knows what's wrong, any help would be much appreciated.

Share this post


Link to post
Share on other sites
pekster

The code itself is good, so your problem is either that it's not finding the pixel, or that the click isn't in the proper place or at the proper time. By proper place I mean that, although it is clicking on a pixel of your requested color, it may not be the proper spot to register the click in whatever app you're scripting.

You could try adding or subtracting a bit from the position of your click to see if that helps.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites
SweatyOgre

you mean the area it searches, or the actual spot it clicks, making it click a little away from the coordinate it returns?

EDIT: also, how can i make it do this until it doesnt find the pixel color any more? just a Do...Until with the until being PixelSearch(430, 340, 710, 455, 6824048) = 0?

Edited by SweatyOgre

Share this post


Link to post
Share on other sites
pekster

you mean the area it searches, or the actual spot it clicks, making it click a little away from the coordinate it returns?

I mean the spot it clicks. Since the code is valid, your problem must be that the click is either not in the correct spot to be detected by your application, or that a right click there doesn't do anything. I suppose the app could be blocking the "script click" and only accepting a real click too.

also, how can i make it do this until it doesnt find the pixel color any more? just a Do...Until with the until being PixelSearch(430, 340, 710, 455, 6824048) = 0?

How about this:

While 1
  $color = PixelSearch(430, 340, 710, 455, 6824048)
  If @error Then ExitLoop
  MouseClick("right",$color[0],$color[1], 1, 0)
  Sleep(100)
WEnd

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.