It compares BMP files to the active window buffer.
code:
FindImage(ImageX, ImageY
, LocalRight, LayersBottom, RegionRight, BiomesBottom
, "Embark.bmp")
That looks for Embark.bmp in the region bounded by the values on the second line and returns the coordinates where found in the variables on the first line. (All coordinates are relative to the absolute top-left of the window, including any border.)My script here only works in windowed mode, though I didn't bother trying to find out why it doesn't work in fullscreen.
Note that I GPLed my script, so you can use any part of it. I've enough free time right now to either play DF or update the script and lately I've chosen to play. (Edit: Of course, the longer I choose to play, the more updating the script will need if and when I get around to it.)
FindImage is actually my own wrapper function to handle errors, debugging and differences in window borders:
code:
FindImage(ByRef X, ByRef Y, Left, Top, Right, Bottom, File)
{
global Debug, XOffset, YOffset, SearchErrorMessage
ImageSearch, X, Y
, Left + XOffset, Top + YOffset
, Right + XOffset, Bottom + YOffset, %File%
If ErrorLevel = 2
{ ; The image may be missing or corrupt.
MsgBox %SearchErrorMessage% %File%.
FileAppend, Could not conduct search for %File%`
, exited script.`n`n
, log.txt
If Debug
FileAppend, %X%`,%Y%`,%Left%`,%Top%`,%Right%`,%Bottom%`,%File%`
,Offsets:%XOffset%`,%YOffset%.`n`n
, debug.txt
ExitApp
}
; The rest of this is for emergency debug only because it
; floods.
; Else If ErrorLevel = 1
; {
; If Debug ; TMI
; FileAppend, Exiting FindImage with ErrorLevel 1 for %File%.`n
; , debug.txt
; ErrorLevel = 1 ; This is only needed with the debug lines.
; Return
; }
; Searched but did not find image. The DF window also might
; have lost focus or the image file doesn't match.
; If Debug ; TMI
; FileAppend, Exiting FindImage with %X%`,%Y% for %File%.`n
; , debug.txt
; ErrorLevel = 0 ; This is only needed with the debug lines.
Return ; The X & Y variables passed in now
} ; contain the pixel coordinates we found.