Sign in to follow this  
Followers 0
rush4hire

Can we get this text from Warcraft III?

13 posts in this topic

Here's a screenshot:

http://www.rush4hire.com/examples1/dd6screen_text.jpg

Now I wanna get the first purple text which is the code for the game:

87398-11706-08392-28698-009

This test didn't seem to work. Gave me blank where there was text there.

sleep(5000)
Opt("WinDetectHiddenText", 1)
$text = WinGetText ( "Warcraft III","" )
MsgBox(0, "Text read was:", $text)

And that works.

You send your bot a command to save your last code, then next game or if you are entering it for that game, send command .dd by itself and it will punch in your code.

But I need a way to bypass stealthbot, cause it's an extra hastle.

If I can make this, it will put Dark Deeds back on the map.

It's a great game, but the code for dd6 is too long, so ppl don't bother with it.

This could work with other wc3 game codes like vQuest, and notd, etc.

Well if I can't get the text off the screen, I would settle for typing it out in from the game.

HotKeySet wont work, cause you want to see the text you're typing.

Can't find _IsPressed function

Thanks! :D

Share this post


Link to post
Share on other sites



no wingettext isnt going to work, its an image on screen its not a plain text label of some sort , your going to have to make a OCR and get the pixelsum ofthe purple pixels and then possibly you can get figure it out

Share this post


Link to post
Share on other sites

Right on.

OCR as in Optical Character Recognition...

Where do you get one of these ?

If I can get this OCR and get this text with it, it would be great!

It's not really where you can "get" one, but how can you "make" one... Do a search maybe?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Neat. I'll check those out immediatley.

Also this came up at the top of my google search for Free+OCR+software

http://www.simpleocr.com/

Good luck with that one (simple ocr that is).

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I'm lookin through those and readin all the comments.

Now as you can see this is all the text I need to get for now out of that screenshot.

Posted Image

That is just the purple text. Just the numbers.

But the Yellow text there might give a place to start for speed maybe.

I'd like to not have to take a screenshot to get it, but right from the screen by command.

And then later I could adapt it for other games.

I'm hoping this post will get me off to a good start.

And thanks again :D

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

sleep(1000)
; #include <Array.au3>

Opt("PixelCoordMode", 0)
$title = WinGetTitle("WC3S", "")
$size = WinGetClientSize ( $title )

$xvar = PixelSearch ( 50, 50, $size[0], $size[1], 0xFF22FF, 10 )

; ~ size = 1024,696
; ~ pos = ~ 249,435

$color = Dec("FF22FF")
$cmin = $color-50
$cmax = $color+1

;~ InputBox ( "title", "Prompt" , $color)
;~ exit

$o=""
$xvar[1] = $xvar[1] + 6
$xvar[0] = $xvar[0] + 6
 For $i = $xvar[0] to $xvar[0]+270
    $t = PixelGetColor($i,$xvar[1])
    If $t > $cmin and $t < $cmax Then
;~     If $t = $color Then
        $o=$o&",1"
    Else
        $o=$o&",0"
    EndIf

Next
InputBox ( "title", "Prompt" , $o )oÝ÷ Ù8b±Ê%¢ºÚ¢uæ}ý·
+)ÓéhÚ碶¢Z+Ì"z·R ¢¶««Þ¶^z÷«Ê±ëajجzÚ¨®
Ê;¬¶ØZµÊ%¢¶¬²é¢­ßÛ-éz'x­j|°k#2¦V§ËhÊ%j×­êÚ¨^­ëaz×±¶+Ø(¶¢ëmç§u§+¢ËÒz(xrº,²Ø¥hmëm«¢Z+j|¦¢·ÖîWl¢g¤wh}¨+Ûr¥æ«­¬|­¶®¶²jË"yÛhÂä"ÛzkºvÊ&z0N­ßÛ0,¨ºÇ¶¨oÝ÷ ÚÚºÚ"µÍY   ÌÍÝH ÌÍØÛÛÜ[

-- edit --

Ok I got 27 colors and I'm not done yet.

I might change methods and use this deal here:

$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )

Maybe get the average color out of all these:

It would be avg red, avg green, avg blue

;15409899
;EB22EB
;16720639
;FF22FF
;15606510
;EE22EE
;13640913
;D024D1
;15540973
;ED22ED
;15475180
;EC21EC
;15409643
;EB21EB
;15737072
;F020F0
;14230230
;D922D6
;15737582
;F022EE
;14820065
;E222E1
;13115077
;C81EC5
;13771218
;D221D2
;12329405
;BC21BD
;16327161
;F921F9
;14887906
;E32BE2
;16196854
;F724F6
;15999475
;F421F3
;15999732
;F422F4
;13640401
;D022D1
;13771475
;D222D3
;13771732
;D223D4
;13771732
;D223D4
;14034134
;D624D6
;13901012
;D41CD4
;16064757
;F520F5
;15082214
;E622E6

I will fix something to at least see where I'm at on the screen. Something to print out the results on a text file.

Edited by rush4hire

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ok even after 27 different color samples it's not really very good.

But here's a pretty good way to test it for now:

http://www.rush4hire.com/examples1/ocr_test1.txt

And it took almost a whole second.

961.218 ms

That would be 8 or 9 times as long on my old computer.

Oh wow. Here's whats takin so long:

$inarray = _ArrayBinarySearch ( $colors, $t )

Without that it took:

235.496 ms

Those underscore functions are the ones people made or something?

Glad I know that now.

Anyhow here's what code I have to give me that:

sleep(1000)
$begin = TimerInit()
#include <Array.au3>
Opt("PixelCoordMode", 0)
$title = WinGetTitle("WC3S", "")
$size = WinGetClientSize ( $title )
$xvar = PixelSearch ( 50, 50, $size[0], $size[1], 0xFF22FF, 10 )

;$color = Dec("FF22FF")
$colors = _ArrayCreate(15409899,16720639,15606510,13640913,15540973,15475180,15409643,15737072,14230230,15737582,14820065,13115077,13771218,12329405,16327161,14887906,16196854,15999475,15999732,13640401,13771475)

; autoIt got some wierd array handling ?
; laff!
_ArrayAdd($colors,13771732)
_ArrayAdd($colors,14034134)
_ArrayAdd($colors,13901012)
_ArrayAdd($colors,16064757)
_ArrayAdd($colors,15082214)

_ArraySort( $colors )

$o=""
$xvar[1] = $xvar[1] - 4
$xvar[0] = $xvar[0] - 4

$file = FileOpen("test.txt", 1)

For $j = $xvar[1] to $xvar[1]+20
  For $i = $xvar[0] to $xvar[0]+290
    $t = PixelGetColor($i,$j)
    $inarray = _ArrayBinarySearch ( $colors, $t )
    If Not @error Then
        $o=$o&""
    Else
        $o=$o&" "
    EndIf
  Next
  FileWriteLine($file, $o)
  $o=""
Next
FileClose($file)
InputBox ( "", "" , TimerDiff($begin) )
Edited by rush4hire

Share this post


Link to post
Share on other sites

whats with all the dots? :D

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Yay I finally got something good!

http://www.rush4hire.com/examples1/ocr_test2.txt

Now I gotta figure out how to seperate the letters and determine what they are.

Here's the code.

sleep(1000)
$begin = TimerInit()

Opt("PixelCoordMode", 0)
$color = 16195831
$title = WinGetTitle("WC3S", "")
$size = WinGetClientSize ( $title )

$xvar = PixelSearch ( 50, 50, $size[0], $size[1], 0xF720F7, 30 )
If @error Then Exit

$xstart = $xvar[0] - 5
$ystart= $xvar[1] - 2

$maxx = $xvar[0]+300
$maxy = $xvar[1]+20
Dim $o[300][20]

$c = 0
For $i = $xstart to $maxx
    $start = $ystart
    While 1
        ;PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
        $arr = PixelSearch ( $i, $start, $i, $maxy, 0xF720F7, 50)
        If @error Then ExitLoop
        $o[$c][$arr[1]-$ystart] = 1
        $start = $arr[1]+1
        If $start = $maxy Then ExitLoop
    WEnd
    $c+=1
Next

Dim $ot
$ot = ""
For $i = 0 to 19
    For $j = 0 to 299
        If $o[$j][$i] = 1 Then
            $ot&=""
        Else
            $ot&=" "
        EndIf
    Next
    $ot&=@CRLF  
Next

FileWrite("test.txt", $ot)

InputBox ( "", "" , TimerDiff($begin) )

Execute time is ~ 300 ms on a leet computer.

Edited by rush4hire

Share this post


Link to post
Share on other sites

Welcome to the OCR world, where every pixel means something, and every number/letter in a different font/size means something else.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

There we are:

Link to the application:

http://www.rush4hire.com/files/ddcodes.exe

;===============================================================================================
;  Save and enter codes from Warcraft 3 custom map Dark Deeds 6
;
;  Hotkeys are:
;  F5 to save
;  F6 to enter code
;
;  Notes:
;  If code is not entered when you attempt to retrieve, code is gotten from file.
;  You have to have the question mark building at the bottom right of the map selected
;   - so it will punch in your code.
;  Getting code from screen takes about 200 ms on my computer.
;   - To test this uncomment the 2 timer functions
;  Will probably work on other Dark Deeds version, as long as the code is pink..
;
;  Author: rush4hire
;  Version: 1.00
;================================================================================================


Global $current_code
Global $current_number_code
HotKeySet ( "{F5}", "HotKey_GetCode" )
HotKeySet ( "{F6}", "enterDDcode" )

;~ Global $file = FileOpen("debuglog.txt", 1)

Global $numbers[12]
$numbers[0]="...111111..."
$numbers[1]=".1111111111."
$numbers[2]="..........1."
$numbers[3]="1..........1"
$numbers[4]="........1..."
$numbers[5]=".11111.....1"
$numbers[6]=".....1111..."
$numbers[7]=".........11."
$numbers[8]="........11.."
$numbers[9]="...111......"
$numbers[10]=".......1...."
$numbers[11]="............"
Global $sendkeys[10] = ["p","q","w","e","r","t","y","u","i","o"]

While 1
        sleep(2000)
WEnd

Func ddResponseSound($e)
        If $e Then
                SoundPlay(@WindowsDir & "\media\tada.wav",1)
        Else
                SoundPlay(@WindowsDir & "\media\chord.wav",1)
        EndIf
EndFunc


Func getLastCodeFromFile($e)
        $size = FileGetSize ("savedDDcodes.txt")
        If @error Then Return ""
        If $size = 0 Then Return ""
        $f = FileOpen ("savedDDcodes.txt", 0)
        $text = FileRead($f, $size)
        FileClose ($f)
        $arr = stringSplit($text, @CRLF, 1)
        If @error Then Return ""
        For $i = $arr[0] to 1 Step -1
                If StringLen($arr[$i]) > 0 Then
                        $x = stringSplit($arr[$i], " ")
                        $x = stringSplit($x[1], ",")
                        $current_number_code = $x[1]
                        Return $x[2]
                EndIf
        Next
        Return ""
EndFunc

Func enterDDcode()
        $len = StringLen($current_code)
        If $len < 20 Then
                $current_code = getLastCodeFromFile(0)
                $len = StringLen($current_code)
                If $len < 20 Then
                        ddResponseSound(0)
                        Return
                EndIf
        EndIf
        ClipPut($current_number_code)
        ddResponseSound(1)
        For $i = 1 to $len
                send(StringMid($current_code,$i,1))
                sleep(30)
        Next
        send("x")
EndFunc

Func HotKey_GetCode()
        $x = getDDcode()
        ddResponseSound($x)
;~      ddResponseSound(getDDcode())
EndFunc


Func getDDcode()
$begin = TimerInit()

Opt("PixelCoordMode", 0)
;$color = 16195831
$title = WinGetTitle("WC3S", "")
$size = WinGetClientSize ( $title )

        ;find about where the pink text is.
$xvar = PixelSearch ( 125, 30, $size[0], $size[1], 0xF720F7, 80 )
If @error Then Return 0
        
        ; There may be some pink text comming first that's too far over to the left.
        ; so start search again below that text.
If $xvar[0] < 175 Then
        $xvar = PixelSearch ( 175, $xvar[1]+20, $size[0], $size[1], 0xF720F7, 30 )
EndIf
If @error Then Return 0

$xstart = $xvar[0] - 3
$ystart= $xvar[1] - 5
; narrow it down
$maxx = $xstart+300
$maxy = $ystart+11

; narrow stuff down
While 1
        $arr = PixelSearch ( $xstart, $ystart, $maxx, $ystart, 0xF720F7, 20)
        If not @error Then ExitLoop
        $ystart+=1
        $maxy+=1
WEnd

While 1
        $arr = PixelSearch ( $xstart, $ystart, $xstart, $maxy, 0xF720F7, 20)
        If Not @error Then ExitLoop
        $xstart+=1
        $maxx+=1
WEnd

Dim $temp[14] = [".",".",".",".",".",".",".",".",".",".",".",".",".","."]
;~ Dim $o[301]

Dim $c = 0
Dim $IsDone = 0
Dim $savestr1 = ""
Dim $savestr2 = ""
;~ FileWriteLine("debuglog.txt", @HOUR & ":" & @MIN)

For $i = $xstart to $maxx
    $start = $ystart
        $x = $temp
    While 1
        ;PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
        $arr = PixelSearch ( $i, $start, $i, $maxy, 0xF720F7, 20)
        If @error Then ExitLoop
        $x[$arr[1]-$ystart] = 1
        $start = $arr[1]+1
        If $start = $maxy Then ExitLoop
        WEnd
;~      $o[$c] = $x
    $t = getnumber($x)
        If $IsDone Then
                ;lookin for a blank colum to start a new letter.
                If $t = 11 Then
                        $IsDone = 0
                EndIf       
    ElseIf $t > -1 and $t < 11 Then
                $IsDone = 1
                If $t = 10 Then
                        $savestr1 &= "-"
;            $c+=1
                Else
                        $savestr1 &= $t
                        $savestr2 &= $sendkeys[$t]
                EndIf
        EndIf
Next
$current_code = $savestr2
ClipPut($savestr1)
$current_number_code = $savestr1
FileWriteLine("savedDDcodes.txt", $savestr1 &","& $savestr2 &" "& @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN &" saved in "& TimerDiff($begin) &" ms")
;~ InputBox ( "", "" , TimerDiff($begin) )
Return 1

EndFunc


Func getnumber($arr)
        $x = dds($arr)
        For $i = 0 to 11
                If $x = $numbers[$i] Then Return $i
        Next
        Return -1
EndFunc


Func dds($arr)
        $x=""
        For $i = 0 to 11
                $x &=  $arr[$i]
        Next
;~     FileWriteLine("debuglog.txt", $x )
;~  & $arr[12] & $arr[13]
        Return $x
EndFunc

Fully tested on screenshots and in the game.

This is the kind of log it makes:

22899-83588-21083-29814-014,wwiooietiiwqpiewoiqrpqr 2006/07/05 00:15 saved in 194.293 ms
87398-11706-08392-28698-009,iueoiqqupypieowwiyoippo 2006/07/05 00:17 saved in 194.028 ms
81508-32367-98502-28946-019,iqtpieweyuoitpwwiorypqo 2006/07/05 00:22 saved in 190.887 ms

There's the actual code as seen in the screenshots, and the keys to send to enter the code on the little number pad in the game.

Aright then. Thanks guys.

Should I post this in scraps when it's been tested for real?

Edited by rush4hire

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  
Followers 0