Jump to content

alternatives to Pixelsearch?


Recommended Posts

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
Link to comment
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
    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".
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...