AutoIt Forums: Mouse clicking on a color that apears - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mouse clicking on a color that apears please point me in the right direction

#1 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 31 October 2009 - 05:41 AM

Hi guys,

How do I go about this? Its using pixelsearch. If a color appears, I want to hold the mouse down on it. I know the mouse commands, I just don't know how to go about the If and Thens to coordinate the mouse clicking when the color appears. Any suggestions? Thanks!
0

#2 User is offline   Minikori 

  • Mass Spammer!
  • PipPipPipPip
  • Group: Full Members
  • Posts: 300
  • Joined: 11-June 08
  • Location:Over There

Posted 31 October 2009 - 05:48 AM

View PostMasonMill, on 30 October 2009 - 10:41 PM, said:

Hi guys,

How do I go about this? Its using pixelsearch. If a color appears, I want to hold the mouse down on it. I know the mouse commands, I just don't know how to go about the If and Thens to coordinate the mouse clicking when the color appears. Any suggestions? Thanks!

Can't really explain this without giving you all the code or seeing what you've tried...
0

#3 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 03 November 2009 - 05:28 AM

Well like I don't even know what kind of command to use to make the mouse cursor land on that color when it appears. For example in a message box, if someone messages me the tab turns red. How do I go about clicking the mouse on that red box when it turns red? I know how to set pixel search up to recognize that it does, so I can give it a coord to click somewhere that i designate but the tab might appear further down. In that case id like the cursor to click there. How would i go about doing that?
0

#4 User is offline   Manjish 

  • !!DT!!
  • PipPipPipPip
  • Group: Full Members
  • Posts: 552
  • Joined: 08-October 08
  • Gender:Male
  • Location:Pune -- India

Posted 03 November 2009 - 10:34 AM

Here's how you can go about it:
Define your x and y co-ordinates in $x and $y.
[ autoIt ]    ( Popup )
If PixelGetColor($x,$y)=0xff0000 Then      MouseClick("left",$x,$y) EndIf  

0

#5 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 03 November 2009 - 06:00 PM

The problem I see with this,if I'm understanding you right, is that say in the case of the tabs on the massage box, the tabs pop up in random spots. So is there way, more or less, you could pixelsearch(x,y,x,y) and where ever the red tab pops up that is where the cursor clicks? The way I understand yours to work is if the color at that coordinate turns red then it clicks at that same coordinate. What I would like the function to do is click where ever in that search area it does turn red because it might happen at random locations.
0

#6 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 04 November 2009 - 01:17 AM

Does anyone else know how to go about doing this?
0

#7 User is offline   AdmiralAlkex 

  • This is not my custom member title!
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,026
  • Joined: 09-April 07
  • Gender:Male
  • Location:Sweden

Posted 04 November 2009 - 04:19 AM

View PostMasonMill, on 04 November 2009 - 01:17 AM, said:

Does anyone else know how to go about doing this?

You need PixelSearch(). See helpfile for details and example.
0

#8 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 04 November 2009 - 06:17 AM

I am very familiar with pixhow del search, that is not the problem I am having. The problem is pixelsearch tells me that the color is there but what function do I use to get the cursor to click at the location where the color appears?
0

#9 User is online   BitByteBit 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 55
  • Joined: 20-May 09

Posted 04 November 2009 - 07:15 AM

[ autoIt ]    ( Popup )
$CoOrd = PixelSearch(30, 30,1024, 768, 0xff0000)   ; Looks for colour 0xff0000. If Not @error Then ;If it exists then MouseClick("Left", $Coord2[0], $Coord2[1], 1, 0) ;Clicks the first instance of that colour else MsgBox(0,"!","Could not find colur") EndIf

0

#10 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 04 November 2009 - 01:29 PM

Awesome! thanks!
0

#11 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 04 November 2009 - 05:14 PM

View PostBitByteBit, on 04 November 2009 - 12:15 AM, said:

[ autoIt ]    ( Popup )
$CoOrd = PixelSearch(30, 30,1024, 768, 0xff0000)   ; Looks for colour 0xff0000. If Not @error Then ;If it exists then MouseClick("Left", $Coord2[0], $Coord2[1], 1, 0) ;Clicks the first instance of that colour else MsgBox(0,"!","Could not find colur") EndIf


I went home and looked at your code, how does it know where the color popped up? Does this code not just see that there is the color I'm looking for and I designate where to click? I am trying to make it click on that location that the color appears. Is this possible?
0

#12 User is offline   Negative1 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 55
  • Joined: 25-February 09
  • Location:95110

Posted 04 November 2009 - 05:20 PM

View PostMasonMill, on 04 November 2009 - 09:14 AM, said:

I went home and looked at your code, how does it know where the color popped up? Does this code not just see that there is the color I'm looking for and I designate where to click? I am trying to make it click on that location that the color appears. Is this possible?


From the help file on pixelsearch:

Return Value
Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
Failure: Sets @error to 1 if color is not found.

PixelSearch does not return a true or false that it found the color it returns the coordinates at which if found the color.
0

#13 User is offline   MasonMill 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 24
  • Joined: 07-August 09

Posted 04 November 2009 - 05:22 PM

View PostNegative1, on 04 November 2009 - 10:20 AM, said:

From the help file on pixelsearch:

Return Value
Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
Failure: Sets @error to 1 if color is not found.

PixelSearch does not return a true or false that it found the color it returns the coordinates at which if found the color.



that's what I'm missing! Thanks!
0

#14 User is offline   anejoblanco 

  • Newbie
  • Group: Full Members
  • Posts: 6
  • Joined: 04-November 09

Posted 04 November 2009 - 05:22 PM

PixelSearch outputs a two element array of where the designated colour was found, in this instance $coOrd[0] being x and $coOrd[1] being y

These variables can be used in place of putting a specific X and Y coordinate in the MouseClick command, the outcome being the script will perform a left mouse click where the colour was found

Also that script will run an error, here's a minor correction

[ autoIt ]    ( Popup )
$CoOrd = PixelSearch(30, 30,1024, 768, 0xff0000)   ; Looks for colour 0xff0000. If Not @error Then ;If it exists then MouseClick("Left", $CoOrd[0], $CoOrd[1], 1, 0) ;Clicks the first instance of that colour else MsgBox(0,"!","Could not find colur") EndIf

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users