Jump to content
Sign in to follow this  
yeads

alternatives to Pixelsearch?

Recommended Posts

yeads

is there a alternative to pixelsearch? something that is precise.

Share this post


Link to post
Share on other sites
kaisies

Depends. What is this for? 

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
yeads

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
Xandy

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
Xandy

REMOVED - See Malkey's awesome example below. :)

Edited by Xandy
My code was incomplete nonsense. Malkey's example is superior.

Share this post


Link to post
Share on other sites
Malkey

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
    Select
        Case _IsPressed("1B") ; Esc button
            ExitLoop
        Case _IsPressed("01") ; Left mouse button
            $aMPos = MouseGetPos()
            MouseMove($aMPos[0] + 5, $aMPos[1], 1)
            Do ; Prevents multiple mouse clicks - ensures one click only.
                Sleep(10)
            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"
            Else
                $sMsg = 'Clicked on"' & StringLeft(ClipGet(), 1) & '" at absolute coordinates (' & $aMPos[0] & ", " & $aMPos[1] & ")" & @LF & @LF & _
                        'Note:' & @LF & 'Press "Esc" to Exit.'
            EndIf
            MsgBox(0, "Result", $sMsg, 3)
            _ClipBoard_SetData("") ; Could not get the script to work properly using ClipPut("") ;
    EndSelect
WEnd

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".
  • Like 1

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  

×