Sign in to follow this  
Followers 0
Dgameman1

Mouseclick on a color?

9 posts in this topic

How can I make it so that if Pixelsearch finds that color, then mouseclick will click on that color?

Share this post


Link to post
Share on other sites



In the example here, PixelSearch, replace the MsgBox line with MouseClick or even ControlClick.

Then it would be

$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If Not @error Then
    MouseClick("primary", 348, 461, 1, 1)
EndIf

That just means that if it found the color, then it will click in the area I tell it too, how can I make it click in the area that the color is found?

Share this post


Link to post
Share on other sites

how can I make it click in the area that the color is found?

Look at the example code more closely.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Hmm, would this be okay?

$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If Not @error Then
    MouseClick("primary", $coord, 1, 1)
EndIf

That won't work, $coord is an array, you would need to do it this way:

MouseClick("primary", $coord[0], $coord[1], 1, 1)
2 people like this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

That won't work, $coord is an array, you would need to do it this way:

MouseClick("primary", $coord[0], $coord[1], 1, 1)

Oh, Thank you so much =D

Share this post


Link to post
Share on other sites

EDIT: It doesn't work good =/

Func start1()
$i = 0
  Do
   WinActivate("[CLASS:Chrome_WidgetWin_0]", "")
  $coord=PixelSearch ( 292, 421, 383, 490, 0x2D7C13 , 0 , 1 )
  if not @error then
   MouseClick("primary", $coord[0], $coord[1], 1, 1)
  elseif @error Then
   sleep(3000)
   endif
  $coord1=PixelSearch ( 205, 756, 275, 816, 0x3CA31F , 0 , 1  )
  if not @error then
   MouseClick("primary", $coord1[0], $coord1[1], 1, 1)
     elseif @error Then
   sleep(3000)
   endif
  $coord2=PixelSearch ( 717, 603, 747, 644, 0xA8E621 , 0 , 1  )
  if not @error then
   MouseClick("primary", $coord2[0], $coord2[1], 1, 1)
     elseif @error Then
   sleep(3000)
   endif
  $coord3=PixelSearch ( 433, 734, 459, 770, 0xA8E621 , 200 , 1  )
  if not @error then
   MouseClick("primary", $coord3[0], $coord3[1], 1, 1)
     elseif @error Then
   sleep(3000)
   endif
  $i = $i + 1
  Until $i = GuiCtrlRead($input1)
EndFunc

First, the mouse moves instantly, i want it to move like a normal mouse, like it used to before i put the pixel search, second, if it doesn't find the color, it just kinda doesnt do anything, how can i make it wait until the color shows up?

Share this post


Link to post
Share on other sites

You're using a value of 1 for the speed parameter in MouseClick. Read the Helpfile if you don't understand what I'm saying. Use a While..WEnd, or similar loop to do things and keep doing them. Read the Helpfile some more.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  
Followers 0