Jump to content
Sign in to follow this  

alternatives to Pixelsearch?

Recommended Posts

As kaisies points out, it is a bit difficult to give you alternatives if we don't know what you're trying to do. In short answer, yes there is almost always something better and more precise than pixelsearch. What that something is will depend on your intended goal.

Share this post

Link to post
Share on other sites

like if i want to make the cursor click on 'b' in a "abc" string. They all have the same color so how can i tell them apart?xy Position wont work either.

Share this post

Link to post
Share on other sites

Check for more than one pixel, compare the results to an array of character pixel data.  I have never done this with variable-width fonts but if one were so inclined it might be possible to do by figuring out the first letter then stepping that letter's width.  Then solve the next letter and step again the last letter's width.

Edited by Xandy

Share this post

Link to post
Share on other sites

This example will select an individual character out of a text field when that character is clicked on.

This example will not select characters from an image, where  OCR is needed.

#include <Misc.au3>
#include <Clipboard.au3>

;Opt("MouseCoordMode", 1) ;1=absolute(default), 0=relative, 2=client

Local $aMPos, $sMsg
MsgBox(0, "Instructions", '"Left mouse click" on a character,' & @LF & '  or,' & @LF & 'Press "Esc" to Exit.' & @LF & @LF & 'Press "Ok" to continue')

While 1
        Case _IsPressed("1B") ; Esc button
        Case _IsPressed("01") ; Left mouse button
            $aMPos = MouseGetPos()
            MouseMove($aMPos[0] + 5, $aMPos[1], 1)
            Do ; Prevents multiple mouse clicks - ensures one click only.
            Until Not _IsPressed("01") ; Left mouse button is released
            ControlSend("", "", "", "^c") ; "" specifies the currently active control.  Copies the highlighted text in that control.
            If _ClipBoard_GetData() = "" Then
                $sMsg = "Cursor not over a specific character when clicked"
                $sMsg = 'Clicked on"' & StringLeft(ClipGet(), 1) & '" at absolute coordinates (' & $aMPos[0] & ", " & $aMPos[1] & ")" & @LF & @LF & _
                        'Note:' & @LF & 'Press "Esc" to Exit.'
            MsgBox(0, "Result", $sMsg, 3)
            _ClipBoard_SetData("") ; Could not get the script to work properly using ClipPut("") ;

When working with strings,  using the PixelSearch function would be way down on the list of possible functions to use.

See String functions in AutoIt help file.

Edited by Malkey
Changed occurences of "Ecs" to "Esc".

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  

  • Create New...