Jump to content

Send a click when position = Color


Kingy
 Share

Recommended Posts

This is a little autoclicker for a game.

When 300,100 is a color 0xFF0404 i need autoit 2 send a left click.

It dosnt need 2 click at 300,100. just click were ever the mouse is at.

how would i do this?

Thanx kingy

Link to comment
Share on other sites

ok i got this far.

$var = PixelGetColor (300,100)
If <$var = 0xFF0404> Then
    MouseClick ( "left" )
EndIf

can i get another hint or push in the right direction.

Kingy

I'm still learning these things myself so please forgive if I am way off.

But wouldn't you need to through the $var check into a loop? The way I understand it that will execute the check just once and exit script.

Maybe something like:

While 1
  $var = PixelGetColor...(etc)
WEnd
Link to comment
Share on other sites

I'm still learning these things myself so please forgive if I am way off.

But wouldn't you need to through the $var check into a loop? The way I understand it that will execute the check just once and exit script.

Maybe something like:

While 1
  $var = PixelGetColor...(etc)
WEnd

so it should look like this?

While 1
  $var = PixelGetColor (300,100)
WEnd
If <$var = 0xFF0404> Then
    MouseClick ( "left" )
EndIf

Thanx man lets see if this works? Will the script keep reloading its self?

Update: No error msgs GOOD...but dosnt work BAD.

Edited by Kingy
Link to comment
Share on other sites

You need to have everything repeated untill you stop the script...

While 1
  $var = PixelGetColor (300,100)
  If $var = 0xFF0404 Then
    MouseClick ( "left" )
  EndIf
WEnd

Next... if the leftclick needs to be at 300, 100 you have to change the MouseClick into

MouseClick("left", 300, 100, 1, 5) - click left at 300, 100, once, and move the mouse there with the speed of 5 (1 is almost instant, 10 is slower, etc)

and if the pixel isn't the right color let's click at the usual spot

While 1
  $var = PixelGetColor (300,100)
  If $var = 0xFF0404 Then
    MouseClick("left", 300, 100, 1, 5)
  else
    MouseClick("left")
  EndIf
WEnd

Now the main issue is that it will click VERY fast - a few hundred times per second posibly so.. at the end of the loop lets wait 0,5 (to only click twice per second). We're gonna do that with

sleep(500)

Last thing... if the pixel is the right color it will move the mouse and the mouse will remain there and keep clicking. But if you want the mouse to go to the position it was before the click to 300, 10 you need to save it's position

While 1
  $var = PixelGetColor (300,100)
  If $var = 0xFF0404 Then
    $before=MouseGetPos()
    MouseClick("left", 300, 100, 1, 2)
    MouseMove(300,100,2)
  else
    MouseClick("left")
  EndIf
  sleep(500)
sleep
WEnd

I hope you get the general idea, i haven't tested the code (don't have autoit on this pc) but it should work as it is. Good luck!

Link to comment
Share on other sites

OK i still cant get this 2 work.

This is what i have...and it should work

; Script Start - Add your code below here 
While 1
  $var = PixelGetColor  (300,100)
  If $var = 0xFF0404 Then
    MouseClick ( "left" )
  EndIf
WEnd
Edited by Kingy
Link to comment
Share on other sites

OK i still cant get this 2 work.

This is what i have...and it should work

; Script Start - Add your code below here 
While 1
  $var = PixelGetColor  (300,100)
  If $var = 0xFF0404 Then
    MouseClick ( "left" )
  EndIf
WEnd

How funny window poped up said "you have been cheating, this has be logged"

So thats why none of this has been working.

What a waste of thime.

Link to comment
Share on other sites

I was just wondering if anyone knows how to set a pixel search variable manually, I mean like this start program msgbox pops up saying to click a certain position on your screen and the spot you clicked the program will record to a variable its color and then it will be used in the auto clicker program

Link to comment
Share on other sites

@user101

http://www.autoitscript.com/forum/index.php?showtopic=107974&view=findpost&p=761369

http://www.autoitscript.com/autoit3/docs/functions/MouseGetPos.htm

I know about those two, and have used them but I tried using the mousegetpos code but it doesn't seem to work when I use the variable it gets saved into, mayber there is something wrong with my code, can you please take a look and spot out my errors http://www.autoitscript.com/forum/index.php?showtopic=108056

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