Jump to content

How to make this more efficient?


 Share

Recommended Posts

I'm trying to make an OCR for IN game stuff in Diablo II, I think it'll work because the characters aren't right up against eachother and you can get a base for each letter through 1 pixel.

But JUST to get the 'code' I'll use for the S in Short Staff it takes 1 second!

Image: (around 75kb, and I'm looking at it inside paint, top left most of the S)

http://www.insolence9.com/iPFU/diablo.bmp

I use the commented out mouse moves + AutoIT Spy's magnify feature, shows me exactly where it's looking :idiot:

Opt("PixelCoordMode", 0)
Opt("MouseCoordMode", 0)

HotKeySet("{SPACE}", "end")

WinActivate("diablo ii in game.bmp")

Sleep(1000)
$color = 12895428

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

$begin = TimerStart()

$msg = ReadText ( 150, 51, $color )

$dif = TimerStop($begin)

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

Func ReadText($startx, $starty, $color)
   $String = ""
   $i = 0
   
 ; Reference:
 ;  D = Down 1 pixel
 ;  R = Right 1 pixel
 ;  S = Down + Right 1 pixel
   
   For $i = 1 to 10
       ;Move 1 pixel down
      $TopLeft_1D = PixelGetColor ( $startx, $starty + 1 ) 
      
    ;MouseMove( $startx, $starty + 1, 10)
    ;Sleep(1000)
    ;MouseMove( 400, 400, 3)
         
      If $TopLeft_1D <> $color Then
          ;Move 1 pixel right 
         $TopLeft_1R = PixelGetColor ( $startx + 1, $starty ) 
         
       ;MouseMove( $startx + 1, $starty, 10)
       ;Sleep(1000)
       ;MouseMove( 400, 400, 3)
         
         If $TopLeft_1R <> $color Then
             ;Move 1 pixel down/right
            $TopLeft_1R1D = PixelGetColor ( $startx + 1, $starty + 1 ) 
            
          ;MouseMove( $startx + 1, $starty + 1, 10)
          ;Sleep(1000)
          ;MouseMove( 400, 400, 3)
            
            If $TopLeft_1R1D = $color Then
                ;If successfully found a pixel right, add S to string
               $startx = $startx + 1
               $starty = $starty + 1
               
               $String = $String & "S"
            EndIf
         Else
            $startx = $startx + 1
             ;If successfully found a pixel right, add R to string
            $String = $String & "R" 
         EndIf
      Else
         $starty = $starty + 1
          ;If successfully found a pixel down, add D to the string
         $String = $String & "D" 
      EndIf

   Next
   
   Return $String
EndFunc

Func End()
   Exit
EndFunc
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.
Link to comment
Share on other sites

eh, all the way at the bottom here :idiot:

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

How often should I bump these? :idiot:

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

It's just to test you big silly :idiot:

I thought of a way to make it atleast a LITTLE faster, lemme see if it works.

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