Jump to content
Sign in to follow this  
Schoening

PixelSearch, Move Mouse to..

Recommended Posts

Schoening

Hey guys ;)(and girls if any ^^)

I've started Playing around with PixelSearch, and after being shocked that it is not using X,Y i found it far smarter^^

For the Simple Version:

I need to PixelSearch the Screen for a Color. And Then Move the Mouse to that place.

Sleep(3000)
$Color = PixelSearch(0, 0, 1000, 1000, 0xE94434, 10)
If Not @error Then
    MouseClick("left", $Color,$Color)
Else
<- The Variable For the Mouse is also Not Working :) How can i move the Mouse to a Variable instead of Set Cordinates?

Advanced:

There is more than one Pixel of The Color.

And There will Most Likely Be More Than One Area With Them on the Screen, but the Mouse is only Supposed To Move to One Area with the Pixels.

So i think i will split the The Screen Into a Grid and Run the PixelSearch Function Until i Find One Window with The Color.

$Color = PixelSearch(0, 0, 100, 100, 0xE94434, 10)
If Not @error Then
Else

MORE ADVANCED !

I need the Script to "Understand 3d"

So i need to Calculate the Range between The Pixelsearch Window and the Center of The Screen.

Got any Help for me:) ?

Pieces of Script, Tutorials, articles ?

Thx for the Help ! :D

Share this post


Link to post
Share on other sites
tomaskir

In Autoit Help under PixelSearch:

Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)

Share this post


Link to post
Share on other sites
Schoening

In Autoit Help under PixelSearch:

Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)

So you are Saying that:
$Color = PixelSearch(500, 300, 800, 600, 0x634f30, 10)
If Not @error Then
MouseClick("Right",$Color,1)
Else
MsgBox(0, "Error", "Error")
EndIf
???

Because That just Moves the Mouse to x= 0 y= 0 cordinates

Share this post


Link to post
Share on other sites
tomaskir

So you are Saying that:

$Color = PixelSearch(500, 300, 800, 600, 0x634f30, 10)
If Not @error Then
MouseClick("Right",$Color,1)
Else
MsgBox(0, "Error", "Error")
EndIf
???

Because That just Moves the Mouse to x= 0 y= 0 cordinates

Do you know how arrays work?

PixelSearch returns an array (Array[0] = x, Array[1] = y)

MouseClick syntax is MouseClick( "button" , x, y)

Comeon, this is pretty simple...

Edited by tomaskir

Share this post


Link to post
Share on other sites
Schoening

I can't see how i make the mouse use pixelsearch array,sorry, just started programming saturday

Edit: but that is not the Big problem :) I figure that one out, thx for the Reminder of the Help File

Edited by Schoening

Share this post


Link to post
Share on other sites
somdcomputerguy

Look at PixelSearch and MouseClick in the Help file. There's working code examples for just about every AutoIt native function in fact.


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

Ok, I have figured the PixelSearch Array thing out now.. Sorry :) I Posted and Started Searching AFTER !

Sorry about that :D

Thx for the Advices ;)

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  

  • Similar Content

    • tiye0405
      By tiye0405
      Hello, 
       
      I currently have a problem that deals with moving the mouse to a given location + or - a certain distance.
      $search1 =_WaitForImageSearch("envelope.bmp", 10, 1, $x, $y, 20)
      $search2 =_WaitForImageSearch("envelope2.bmp", 10, 1, $x, $y, 20)
       
      If $search1 = 1 Then
                  Sleep(100)
                  MouseMove($x, $y, 10)
                  sleep(99)
                  MouseClick("left")
                 Sleep(99)
      ElseIf $search2 = 1 Then
                 Sleep(100)
                 MouseMove($x, $y2, 10)
                 sleep(99)
                 MouseClick("left")
                 Sleep(100)
      Else
                Sleep(150)
                MouseMove($x2, $y, 10)
                Sleep(150)
                MouseClick("left")
               Sleep(150)
      EndIf
      The problem about this is that i defined $x2 = $x - 175  and $y2 = $y + 35
      I got these numbers ( 175 and 35) with the autoit helper and just subtracted point where it is to the point its supposed to move but it doesnt work.

      is there any proper way to find the distance between 2 points in pixels?
       
      Imgsearch doesnt always work for this picture so i want it to have a backup
       
      edit: could it be that the definition of $x and $y  from the previous image search arent there anymore and thats why it moves my mouse to strange places? 
      is there a way to preserve the $x $y from the previous img search untill the next succesful one?
       
       
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.
      But its not working for me. I'm not sure what mistake I do.
      I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".
      Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).
      #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error) _ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") _OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error) Any help is deeply appreciated. Thanks in advance.
      Thanks and regards,
      Gowrisankar R.
    • Daka
      By Daka
      I find it very weird:
      if I run like this:
           Local $aCoord = PixelSearch($posX, $posY, $sizeX, $sizeY, '0xFF455E')
      works fine!
      If I run like this:
          Local $metaColor1 = '0xFF455E' or like this Local $metaColor1 = "0xFF455E" or Local $metaColor1 = "'0xFF455E'"
          Local $aCoord = PixelSearch($posX, $posY, $sizeX, $sizeY, $color)
      it doesn't want to work! So something with variable is not working and yes if I print it out like this:
      ConsoleWrite(@LF & $posX & ":"& $posY & ":"& $sizeX & ":" & $sizeY & ":" & $color&@LF)
      771:80:833:151:0xFF455E

      So I dont see the problem, maybe some of you people?
    • squidol
      By squidol
      I need help about pixel search. The problem with the script below is that PixelSearch does not continue on the coordinates where it has stopped.
      When the first pixelsearch finds the 1st pixel, it should move the mouse over it and new pixels would appear just like hovering over menus. Then upon hover, there would be another PixelSearch to see if the second red pixel is found. If not found, then it should resume the first PixelSearch instead of starting from left to right again. 
      For example we are doing a pixelsearch on two straight lines with coordinates  [x,y]  :
      [0,0] [1,0] [2,0]
      [1,0] [1,1] [1,2]
      Pixelsearch finds the coordinate [1,0] matching our color. So it checks the pixel just below it which is [1,1] to see if it is color red. If not red then it should continue searching starting on coordinates [2,0] instead of going back to [0,0]
      Local $bflag = False Do     ToolTip("finding..",0,0,"")     Sleep(500)     $var = PixelSearch(591, 169, 1365, 740, 0x464950,50) ; look for initial pixel     If Not @error Then ;         MouseMove($var[0],$var[1],0) ;move on the button to show new selections, new pixels         sleep(1000)         ;search for the red pixel on an area above the first pixel coords which was          ;generated when mouse cursor was hovered on the first pixel found.         $redpixel = PixelSearch($var[0]-50,$var[1]-50,$var[0]+50,$var[1]+50,0xFF0048)          If Not @error Then ; Found the 2nd pixel                 ToolTip("found...",0,0,"")             $bflag = True          EndIf     EndIf Until $bflag I can pay 50USD through Paypal for a working solution. thanks   
    • MrMajorThorburn
      By MrMajorThorburn
      Using sample code:
      #include <MsgBoxConstants.au3> ; Find a pure red pixel in the range 0,0-20,300
      Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Pure Not Found")
      EndIf ; Find a pure red pixel or a red pixel within 10 shades variations of pure red
      $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Variant Not Found")
      EndIf   and the attached screenshot which has Pure Red (FF0000) in one icon in the area being searched. Would someone please check this out for me?
×