Sign in to follow this  
Followers 0
Ster

match bitmap file to screen area (ImageSearch)

18 posts in this topic




Hi,

the autohotkey has some good things perhaps an idea to combine the 2 into one ?

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

Yes, this would be a good function to add. I wouldn't mind if this function would be ripped from AHK, they have used a lot of AutoIt's code :)

Share this post


Link to post
Share on other sites

Yes, this would be a good function to add. I wouldn't mind if this function would be ripped from AHK, they have used a lot of AutoIt's code  :)

<{POST_SNAPBACK}>

So you want us to throw away our ideals and be a bunch of dirty rat bastards that steal source code? I think that'd be a rather hypocritical thing for us to do given one of the primary reasons AutoIt is closed/limited source is due to a certain group leeching our code without even being courteous enough to ask us first.

Share this post


Link to post
Share on other sites

I think a combination of PixelSearch and PixelChecksum could do something... I will go test...

Lar.

<{POST_SNAPBACK}>

Nice words... :)

I didn't know of this function (at this moment), I don't use AHK...but it's interesting because, looks like this func, works with files.

Also, would be nice a GUI function that extracts a region of an image file and can be used like resource over a window... (of course, I believe that could be finished with DLLCall)

Share this post


Link to post
Share on other sites

So you want us to throw away our ideals and be a bunch of dirty rat bastards that steal source code?  I think that'd be a rather hypocritical thing for us to do given one of the primary reasons AutoIt is closed/limited source is due to a certain group leeching our code without even being courteous enough to ask us first.

<{POST_SNAPBACK}>

No, that's not what I'm saying. You can always take the high road and ask AHK developer / give him credits on the func description. I'm just saying AHK source code might be worth studying to give ideas how this can be done.

@Larry: That's very good but doesn't really do exactly the same (not reading image info from files)

A function coded with C++ and added to AutoIt would probably perform much better.

Share this post


Link to post
Share on other sites

I'm just saying AHK source code might be worth studying to give ideas how this can be done.

This is why reading their source is pointless:

I just looked at the ImageSearch function source in AHK and it is a modification of my PixelSearch function from AU3.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I have looked at the whole thing, because I wanted to see who AutoIt's competitor's are, and I noticed they gave Jon some credit, but not very much in their helpfile. They have most everything AutoIt used to offer.

I looked at how they had everything setup, and its just like AutoIt... really kinda upset me that someone would do that. They even have a quite large support forum. Its odd.

Edit: This seems to be the case with alot of things I have noticed... splits and such, except this isnt a split they just took the source and went with it. I am glad Jon saw this and limited the source code when he did. Competition is one thing, but just taking and claiming it for your own is a totally different story.

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

I didn't mean to step to anyones toes here. I've just been in the forum long enough to know that AHK is taking code from Jon, that's all.

@Larry: For test automation image file is better. Humans can easily spot a difference in image file, but not in Pixelchecksum. Maybe both ways could be supported?

I myself don't have any specific need at the moment, I'm just saying that this function would be really good add-on...

Share this post


Link to post
Share on other sites

I didn't mean to step to anyones toes here. I've just been in the forum long enough to know that AHK is taking code from Jon, that's all.

@Larry: For test automation image file is better. Humans can easily spot a difference in image file, but not in Pixelchecksum. Maybe both ways could be supported?

I myself don't have any specific need at the moment, I'm just saying that this function would be really good add-on...

<{POST_SNAPBACK}>

I know you didnt mean to step on any toes. :) At the same time this is somewhat a sore subject for the developers, because someone has just taken their code barely gave any recognition to who wrote it, and claiming it as their own.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

whipped together something similar that should be useful... bad code... uncommented... but works...

;----------------------------------------------------------------
;;;;;The very first pixel should be as unique as possible...
;----------------------------------------------------------------
$info = _ImageSearchGetInfo(326,313,339,331)

$xy = _ImageSearch(0,0,640,480,$info)
If Not @error Then MsgBox(4096,"",$xy[0] & "," & $xy[1])

Func _ImageSearchGetInfo($l,$t,$r,$b)
    Dim $array[4]
    $color = PixelGetColor($l, $t)
    $chksum = PixelChecksum($l, $t, $r, $b)
    $array[0] = $r - $l
    $array[1] = $b - $t
    $array[2] = $color
    $array[3] = $chksum
    Return $array
EndFunc

Func _ImageSearch($left,$top,$width,$height,$ISarray)
    $x = $left
    $y = $top
    $boundX = $left + $width
    $boundY = (($top + $height) - $ISarray[1])

    While $x <= $boundX And $y <= $boundY
        $initXY = PixelSearch($x, $y, $boundX, $y, $ISarray[2])
        If Not @error Then
            If $ISarray[3] = PixelChecksum($initXY[0], $initXY[1], $initXY[0] + $ISarray[0], $initXY[1] + $ISarray[1]) Then
                Return $initXY
            Else
                If ($initXY[0] + $ISarray[0]) > $boundX Then
                    $y = $y + 1
                Else
                    $x = $initXY[0] + 1
                EndIf
            EndIf
        Else
            $y = $y + 1
        EndIf
    WEnd
    SetError(1)
EndFunc

gotta go get ready for a road trip...

Lar.

<{POST_SNAPBACK}>

Hi Larry,

I'm interested in this code you wrote. Which part compares the source image? How is the source image loaded? I'm planning to use it in the script I'm building now since I can't retrieve the classname of a text inside a dialog box.

Thanks,

Neil

Share this post


Link to post
Share on other sites

Okay specifically why i wanted this function is that in a game i play, i want to drop items from my inventory based on an original cropped bitmap i would save to file.

now a matching image will generally be the same, except the background of the inventory window is not consistent. therefore i require the shade-difference option.

if i could understand how to open a bitmap and parse each pixel, say x:1-41 and y:1-41, then i could write my own utility by using pixelsearch. however i do not know how to load a bitmap nor parse each pixel -- if someone could give a breif example of this i would GREATLY APRECIATE it.

p.s. i was also thinking of using imagemagick COMPARE but the download seems to be source only files.

Share this post


Link to post
Share on other sites

_ImageSearchGetInfo takes a snapshot and saves th info to an array. You can record this info however you want. pass the array to _ImageSearch along with the left,top pixel and width,height to search.

Lar.

<{POST_SNAPBACK}>

Am I correct that the array passed to _ImageSearch will be used to compare the image or array found in the left,top pixel and width,height supplied?

Assuming I have kept a .gif file of the image I want to compare with, how will I load this image? And how will I use your function to compare it?

Thanks again!

Neil

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I just looked at the ImageSearch function source in AHK and it is a modification of my PixelSearch function from AU3.

That is false. Both ImageSearch and the fast-mode PixelSearch were written from scratch by Aurelian Maga (and I made some small refinements, such as PNG and transparent-icon support). Anyone wishing proof can download the source code, in which the ImageSearch function can be found by searching script2.cpp for "ImageSearch was created by Aurelian Maga."

Edit: Fixed typos.

Edited by cmallett

Share this post


Link to post
Share on other sites

[...]

if i could understand how to open a bitmap and parse each pixel [...] then i could write my own utility by using pixelsearch.  [...] if someone could give a brief example of this i would GREATLY APRECIATE it.

[...]

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

I have to give credit to AHK people about this ImageSearch function. It's fast enough and works very well.

Share this post


Link to post
Share on other sites

Hate to bump a dead thread but is there a way to do this in AutoIt? My search has only yeilded me this and I am not sure I completely understand the use of Larry's function...

Share this post


Link to post
Share on other sites

murky024,

Rather than necro a dead thread, please just open a new one next time. ;)

You need to sharpen up your searching skills - this popped up as top of the list for me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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