Skip to content

After few hours of working suddenly imagesearch stopping to work #55

@howcio

Description

@howcio

part of my code

settimer, CaptureRegion, 500
global stayTime := 0

try {
        ;getting first image to a variable after running the script
	global pStream2 := ImagePutStream([plus(A_ScreenWidth - 165 ),28,108,108])
	}
	catch e {
		sleep, 100 ;just to ignore errors
	}



...
loop with my things...
...

CaptureRegion()
{
	    

    global pStream2, stayTime
	ListLines, Off
    try {
         pStream := ImagePutStream([plus(A_ScreenWidth - 165 ),28,108,108])
         if ImageEqual(pStream, pStream2){
             stayTime += 1 
         }Else{
             pStream2 := pStream
             stayTime := 0
         }
    }
    catch e {
        sleep, 100 ;just to ignore errors
    }
	ListLines, On
}

basically i wrote a bot, and im using imageput for checking if my character is moving or not, so i check every 500ms if "map" in the game changed, which mean character moved. The problem is, that after few hours of working something happening and every imagesearch in my script is stopping to work, for example i made a hotkey like that:

F12::
	imagesearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight,  *70, img\test.png
       msgbox, %x%, %y%
return

for few hours it works fine, but when it broke then it return just empty strings, so it mean it doesnt find the image.
reloading script is fixing the problem, but i would prefer no to reload it every 30min.

I was thinking maybe its some kind of memory leak, but idk
im using ahk 1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions