Spawnova / ShinsImageScanClass

A library/class for fast AutoHotKey image/pixel searching
MIT License
74 stars 12 forks source link

AHK V2 Throws an error on unassigned variables #21

Closed MetaMoRpheXx closed 7 months ago

MetaMoRpheXx commented 1 year ago

Hi, I'm trying to use the v2 of this class but it seems to throw an error pointing to the ImageArray method:

    217: }
    ...
    235: {
▶   236: If (!c := this.ImageArray(image,a,variance,centerResults))
    237: Return 0
    238: min := maxRadius

The code that I'm using for testing:

...

scan := new ShinsImageScanClass(defaultApp)
scanImageArray := []

MsgBox scan.ImageArray("base.png", scanImageArray)

It seems that same thing happens on any class method I test.

Spawnova commented 1 year ago

Ahk v2 has different syntax, I don't personally use v2 so I can't say exactly, but I think it should look like this

scan := ShinsImageScanClass("window title")

MsgBox scan.ImageArray("base.png", &scanImageArray)
MetaMoRpheXx commented 1 year ago

Thanks for the response, I did try that yesterday but the error points on the same line. I was able to fix it by initializing the variable. I'll create a pull request if you don't mind (#22).

In V2, creating an instance of the class by using "new" throws an error as well: scan := new ShinsImageScanClass(defaultApp) ; throws an error scan := ShinsImageScanClass(defaultApp) ; doesn't throw an error

Spawnova commented 1 year ago

Ah ok I see the issue, there was a missing ampersand, the issue has been fixed

ahk v2 does not use new when instantiating a new class

thanks for the feedback, let me know if anything else comes up