Jump to content

Scroll one pixel at a time?


Recommended Posts

Hi. I'm trying to write a background script that scrolls through another window's control, one pixel at a time, and captures a really tall image of it.

Is there such a way to scroll "one pixel at a time"? All I can really think of right now is sending a pageup/pagedown key, or sending the up/down keys. Any better ideas?

Link to comment
Share on other sites

The Trick here is the Function "OCR"

#include <GuiConstants.au3>

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


Dim $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


GUICreate("test window", 400, 300)
GUICtrlCreateLabel("Array position", 5, 25)
GUICtrlCreateLabel("$Ax and $Ay position", 110, 25)
;GUICtrlCreatePic(@ScriptDir &"\colors.jpg", 145, 0, 40, 21)
GUICtrlSetBkColor(-1,0x00ff00)  ; Green
GUICtrlCreateLabel("", 145, 8, 28, 8)
GUICtrlSetBkColor(-1,0xff0000)    ; Red
GUICtrlCreateLabel("", 145, 16, 28, 8)
GUICtrlSetBkColor(-1,"")    ; Black
GUICtrlCreateLabel("RGB Mouse Color Found ", 250, 25)
$color1 = GUICtrlCreateLabel("", 300, 3, 20, 20)
$Edit1 = GUICtrlCreateEdit("", 50, 50, 300, 200)
GUICtrlCreateLabel("Press *Pause* to Stop/Resume   or   Press *ESC* to Exit ", 60, 270)
GUISetState()

_ocr(150, 0, 170, 20)


While GUIGetMsg() <> -3
WEnd

Func _ocr($Ax, $Ay, $Dx, $Dy)
    
    $By = $Ay
    $width = $Dx - $Ax
    $length = $Dy - $Ay
    
    Dim $char[$width][$length]
    
    For $xwidth = 0 To $width -1
        $Ax = $Ax +1
        $Ay = $By
        For $xlength = 0 To $length -1
            $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6)
            GUICtrlSetData($Edit1, "Hex Color at " & $Ax & " and " & $Ay & " is " & $char[$xwidth][$xlength] & @CRLF, 1)
            MouseMove($Ax + 2, $Ay)
            GUICtrlSetBkColor( $color1, (PixelGetColor($Ax, $Ay)))
            Sleep(100)
            $Ay= $Ay+1
        Next
    Next
    Return $char
EndFunc  

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

8)

NEWHeader1.png

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