Jump to content

A pretty simple problem


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

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

  • Recently Browsing   0 members

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