Sign in to follow this  
Followers 0
zapper9987

Count how many times a single image apears on the screen?

5 posts in this topic

#1 ·  Posted (edited)

Hello, I have been using the imagesearch.dll and au3 to scan the screen for an image, and it has worked superbly. Now, I wish to count how many times a single image appears on the screen. Is this possible?

Thanks for your time and help.

Edited by zapper9987

Share this post


Link to post
Share on other sites



Hello, I have been using the imagesearch.dll and au3 to scan the screen for an image, and it has worked superbly. Now, I wish to count how many times a single image appears on the screen. Is this possible?

Thanks for your time and help.

Global $iCount = 0

And do

$iCount += 1 in the function if image is found.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Global $iCount = 0

And do

$iCount += 1 in the function if image is found.

Thanks, but what do you mean? I am using the imagesearch.ua3, that calls the imagesearch.dll file. Inside my script, I call this from the ua3 file.

Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
   return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
EndFunc

Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

    ; If error exit
    if $result[0]="0" then return 0
    
    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0],"|")
   
   $x=Int(Number($array[2]))
   $y=Int(Number($array[3]))
   if $resultPosition=1 then
      $x=$x + Int(Number($array[4])/2)
      $y=$y + Int(Number($array[5])/2)
   endif
   return 1
EndFunc

So.. From what I see, since the DLL returns no number count, this is impossible? If I do it over and over, it of course just sees the same one. Over. And over.

Edited by zapper9987

Share this post


Link to post
Share on other sites

For $i = 0 To 5
    MsgBox(0,"",$i)
Next

$i = -1
Do
    $i += 1
    MsgBox(0,"",$i)
Until $i = 5

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 233, 66, 192, 124)
$Label1 = GUICtrlCreateLabel(1, 184, 40, 36, 17)
$Button1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Label1,GUICtrlRead($Label1)+1)
    EndSwitch
WEnd

Come on... >_<

Share this post


Link to post
Share on other sites

No. This is not simple counting where I can just bump up a variable every time a function is called. I wanted to know if anyone knew how to extend the imagesearch script to count the number of a single image instance apearing on one screen at one time. I do not see to know how many times its seen the same image. That will not work for what I am trying to do. Instead, does anyone know an alternative to using the imagesearch.dll/ua3?

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