Jump to content
Sign in to follow this  

Screenshot Reading

Recommended Posts

Hey guys,

I'm a tad new to autoit3, i've been learning and done a few quick login scripts with colors and timers. But now i'd like to make a bot for a game ( for educational purposes of course :) ).

To do this, i need to make it read a screenshot ( This one, and a few othersPosted Image, it is saved on my system as invalid.bmp.

Unfortunatly, i also need to make it so it looks for that in a certain location...and that would be approx. here on a 1024x768 screen.

Posted Image

And i can't find a tutorial ( Properly) to make it do this.

Also, i need to make it so if it doesn't find that screenshot on the screen, it goes to the next command...which should be something like turning around and moving the mouse a bit (Simple stuff).

I have no idea how to do either of those commands, so if you could, please tell me what they are! :)

Thanks in advance guys,


Share this post

Link to post
Share on other sites

I'm assuming your wanting to read the screen and not the bmp file. Look into PixelChecksum ,PixelGetColor, PixelSearch. That should get you started.

Share this post

Link to post
Share on other sites

i have seen ocr's for autoit and found a pretty good one and made a udf for it

EDIT: also to get the screen shot to ocr look up autolib and in there they have a bit of screencap functions.

#include <Array.au3>

; Function Name:    OCRImage($imagefile)
; Description:      Gets text out of an image.
; Parameter(s):     $imagefile - The file to ocr
; Requirement(s):   Office 2003 or above
; Return Value(s):  Returns a string of the words.
; Author(s):        ptrex, bam5
; http://msdn2.microsoft.com/en-us/library/a...office.11).aspx

Func OCRImage($imagefile)
    Dim $miDoc, $Doc
    Dim $str
    Dim $oWord
    Dim $sArray[500]

    Const $miLANG_CZECH = 5
    Const $miLANG_DANISH = 6
    Const $miLANG_DUTCH = 19
    Const $miLANG_ENGLISH = 9
    Const $miLANG_FINNISH = 11
    Const $miLANG_FRENCH = 12
    Const $miLANG_GERMAN = 7
    Const $miLANG_GREEK = 8
    Const $miLANG_HUNGARIAN = 14
    Const $miLANG_ITALIAN = 16
    Const $miLANG_JAPANESE = 17
    Const $miLANG_KOREAN = 18
    Const $miLANG_NORWEGIAN = 20
    Const $miLANG_POLISH = 21
    Const $miLANG_PORTUGUESE = 22
    Const $miLANG_RUSSIAN = 25
    Const $miLANG_SPANISH = 10
    Const $miLANG_SWEDISH = 29
    Const $miLANG_TURKISH = 31
    Const $miLANG_SYSDEFAULT = 2048

    $miDoc = ObjCreate("MODI.Document")
    $miDocView = ObjCreate("MiDocViewer.MiDocView")

    $miDoc.Ocr($miLANG_ENGLISH, True, False)

    $i = 0

    For $oWord in $miDoc.Images(0).Layout.Words
        $str = $str & $oWord.text & ' '
        $sArray [$i] = $oWord.text
        $i = $i + 1

    Return $str

you need office 03 or above.

Edited by bam5

Share this post

Link to post
Share on other sites

To fully read the text an OCR would be required in some fashion. However if you just need to see if the that message appears in a certain area of the screen you can simply scan that area for a change in pixel color and or pattern using the pixel functions.

Share this post

Link to post
Share on other sites

For this i'll use a simpler picture, this one: Posted Image

If you're wondering, it's from Runescape.

The nearest font i can give it to is 'Fixedsys'. Though i'm not quite sure, it seems as though it's a 'not as bold' version of Fixesys.

Heres 'FixedSys' Posted Image

Size...mmmm....About 8.

And how do i make it look at that certain location on the screen? I've been looking everywhere! If one of you could please give me the command i'd be greatfull :).

And yes, all i need it to do is see if that picture is there on XX part of the screen, if it is, go onto specified command, if not, go onto specified command. I seriously need that command in general to surpass random events, i don't want it to pause every time i tell it to search for random events to wait for each of them.

Thanks for your help so far guys!

Edited by makeshift

Share this post

Link to post
Share on other sites

I'm being annoying again.

Can anybody please help me with this? I've scoured google, yahoo, msn search for a tutorial on something like this, but i can't find...squat. I'm working on various bots for various games, this is the absolute only thing i need to complete most of my scripts. I'm also working on an autoit tutorial website ( Still under construction. If you want to check it out and maybe submit a tutorial message me), and an answer would be very helpful so i could also put it on there.

Thanks again.

EDIT: Just found a tutorial...it's LIKE what i need, the function PixelCheckSum ( Which was mentioned...) looks for a change in that area, the only problem for me is that there will be lots...and lots...of changes in that area, i need to look for a certain one.

( Tutorial: http://www.autoitscript.com/autoit3/docs/f...xelChecksum.htm )

Edited by makeshift

Share this post

Link to post
Share on other sites

the PixelChecksum() function returns a value based on the pixels within the area you specify.

So you can search the area to the bottom of the screen when it says: You swing your pick at the rock, keep that value (an example: 1942411134).

Then you can check the area again, and if the checksum equals the previous value (in my example 1942411134), it should say: You swing your pick at the rock.

I'm not sure if this works, I will test it when I come home, but if I understand the function correctly, it should work.

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  

  • Create New...