Jump to content
Sign in to follow this  
Insolence

Trying to 'read' text from inside a game

Recommended Posts

Insolence

Basically what I'm trying to do is look at the base pixels of each letter. Connecting as many as I can by searching 1 down 1 right then searching 1 up 1 left.

Then saving the results wherever the correct pixel is found, returning stuff like such:

D D R D D R R L U U (10 results hopefully, I think a few will be less)

Right now it only reads 1 thing at a time, I can't figure out how to get from letter-to-letter.

I think that will be enough to uniquely identify each letter, but I'm stuck as to how I'll scan each line of text, and efficiently.

Here's the picture:

http://www.insolence9.com/images/diabloii.bmp (255 KB, copy and paste)

Here's the code so far (I've just been playing with it, a little commented out debuggers and such)

Sleep(2000)
$color = 5263440

;$msg = ReadText ( 61, 45, 339, 58, $color )  Y

$begin = TimerStart()

$msg = ReadText ( 70, 45, 339, 300, $color )

$dif = TimerStop($begin)

MsgBox("", "", $msg & " scanned in: " & $dif)

Func ReadText($startx, $starty, $endx, $endy, $color)
   $TopLeft = PixelSearch ( $startx, $starty, $endx, $endy, $color )
   
   $String = ""
   $i = 0
   $GoingDown = 1
   
   For $i = 1 to 10
      If $GoingDown = 1 Then
         $TopLeft_1D = PixelGetColor ( $TopLeft[0], $TopLeft[1] + 1 );Move 1 pixel down
         
    ;MouseMove( $TopLeft[0], $TopLeft[1] + 1, 10)
    ;Sleep(1000)
    ;MouseMove( 400, 400, 3)
            
         If $TopLeft_1D <> $color Then
            $TopLeft_1R = PixelGetColor ( $TopLeft[0] + 1, $TopLeft[1] );Move 1 pixel right 
            
       ;MouseMove( $TopLeft[0] + 1, $TopLeft[1], 10)
       ;Sleep(1000)
       ;MouseMove( 400, 400, 3)
            
            If $TopLeft_1R <> $color Then
               $GoingDown = 0;We started going up, can't go down now.
            Else
               $TopLeft[0] = $TopLeft[0] + 1
               $String = $String & "R";If successfully found a pixel right, add R to string
            EndIf
         Else
            $TopLeft[1] = $TopLeft[1] + 1
            $String = $String & "D";If successfully found a pixel down, add D to the string
         EndIf
      Else
      
    ;We can't go down-right any more, so we're going up-left
         
         $TopLeft_1U = PixelGetColor ( $TopLeft[0], $TopLeft[1] - 1 );Move 1 pixel up
         
       ;MouseMove( $TopLeft[0], $TopLeft[1] - 1, 10)
       ;Sleep(1000)
       ;MouseMove( 400, 400, 3)
         
         If $TopLeft_1U <> $color Then
            $TopLeft_1L = PixelGetColor ( $TopLeft[0] - 1, $TopLeft[1] );Move 1 pixel left
            
       ;MouseMove( $TopLeft[0] - 1, $TopLeft[1], 10)
       ;Sleep(1000)
       ;MouseMove( 400, 400, 3)
            
            If $TopLeft_1L == $color Then
               $TopLeft[0] = $TopLeft[0] - 1
               $String = $String & "L";If successfully found a pixel left, add L to string
            EndIf
         
         Else
            $TopLeft[1] = $TopLeft[1] - 1
            $String = $String & "U";If successfully found a pixel up, add R to the string
         EndIf
      EndIf
   Next
   
   Return $String
EndFunc

I threw it in a function to make it a little more organized. Any problems you see, or suggestions you have, PLEASE don't hessitate to rip me to shreds :idiot:

Also, I tested this with the AU3Spy and the Magnifier enabled (hence the mouse moves) it helped quite a bit. Enable those commented out lines and use the magnifier to see what's going on.

Edited by Insolence

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

Thanks a ton for that link.

I'll need to contact Larry.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

Ehhh, bump*


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

Thanks Larry, was waiting for ya :idiot:

I COULD use pixel variation, though, right?


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.