 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Traderhut Guest
|
Posted: Sun Mar 30, 2008 6:30 am Post subject: ImageSearch is flakey |
|
|
Hi,
I'm doing a ImageSearch for an image, and I wrapped it in a function, i.e:
IsThere(x,y Width, Height, Image)
{
ImageSearch FoundX, FoundY, x, y, x+width, y+height, c:\foo\%Image%.gif
Then I check the ErrorLevel = 2, and it is under the following bizarre conditions...
If( X > 125) AND (y < 195)
Image is found
Else
It sets ErrorLevel =2
And I'm getting nothing in ErrorMessage (I presume, that there is a function / variable that tells me WHAT screwed up, Error levels went out with the 80's. My guess was wrong though.)
The window is 512x512, the image is 72x12, (and 10 other images at other places work fine) Changing the image to another one that works, can change the X or Y needed to work, but it can't remove the problem.
The window has focus, and is fully visible.
This is a great function by the way...
I'm giving up for the night...
-Chert |
|
| Back to top |
|
 |
Traderhut Guest
|
Posted: Sat Apr 05, 2008 4:42 am Post subject: Further strangeness... |
|
|
Here is another weirdity....
I have a game that I'm monitoring, and if I turn one direction and execute the script it tells me that it can find the image just fine.
If I turn another direction (the image in that are is different) then it tells me Error. (ErrorNumber = 2)
I know it said something about smaller images work better - and I originally assumed that would be because they would require less time to do the scan, however, maybe it is just buggy and smaller images don't trip the bug as often?
If I could do a screen capture of a given area (the AHK must be able to do that, or it couldn't do this function) and save them to a file - I could do the check myself...
Is there a way to do a plug-in to capture and compare images? I only care if a given image is displayed in a given area, or not.. Nothing fancy, just a pixel by pixel compare of that area...
-Traderhut |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2364 Location: Australia, Qld
|
Posted: Sat Apr 05, 2008 5:42 am Post subject: Re: ImageSearch is flakey |
|
|
| Traderhut wrote: | If( X > 125) AND (y < 195)
Image is found
Else
It sets ErrorLevel =2 | Perhaps the X2/Y2 parameters exclude the image from the search area. What happens if you specify the entire screen as the search area?
| Code: | | ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %Image% |
| Quote: | | And I'm getting nothing in ErrorMessage | What is ErrorMessage? It certainly isn't a built-in variable.
| Quote: | | I presume, that there is a function / variable that tells me WHAT screwed up, | You won't get anything more specific than ErrorLevel.
| Quote: | | I have a game that I'm monitoring, and if I turn one direction and execute the script it tells me that it can find the image just fine. | Is it a 3D game? What are you searching for? ImageSearch is designed to search for two-dimensional images on the screen. |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Apr 05, 2008 9:49 am Post subject: Re: ImageSearch is flakey |
|
|
| Traderhut wrote: |
Then I check the ErrorLevel = 2, and it is under the following bizarre conditions...
If( X > 125) AND (y < 195)
Image is found
Else
It sets ErrorLevel =2
|
It has been my experience that errorlevel=2 most often indicates a problem with the %Image% file.
(i.e file not found or corrupted file)
| AHK help wrote wrote: | ErrorLevel is set to 0 if the image was found in the specified region, 1 if it was not found,
or 2 if there was a problem that prevented the command from conducting the search
(such as failure to open the image file or a badly formatted option). |
|
|
| Back to top |
|
 |
Traderhut
Joined: 05 Apr 2008 Posts: 8 Location: DFW
|
Posted: Sat Apr 05, 2008 8:55 pm Post subject: Sigh.. |
|
|
Ok, the x1, y1, x2, y2 are constant.
the game is 2D, using a terminal emulator - I can screen capture it with 'snagit32' or any other screen capture program.. It is a simple window with simple drawing. It doesn't use DirectX, OpenGl or hardware accelleration that would cause problems.
The image is not corrupted, and WORKS with AHK sometimes..
However, if I move the x1/y1 location (making the window to search larger in the case of x < 125, or moving it down in the case of Y > 195 (y2 goes up by the same amount, if you look at the function)
Then it blows up.
I've also had it blow up if I change the image to search (the game is VERY static, there are NO updates of the screen unless I press a key.)
I've also had it blow up on an image that worked a few seconds ago, and had to close and restart the script to get it to like the image again..
The comment about ErrorMessage was, I guess a request for feature... It would SURE be nice to have SOME (standard way, heck, I'd take a hack right now) to know what it didn't like about the request... Was the image to search too large/small? (90x90) was the image to big? (12x60 or something like that) Wrong phase of the moon? OS returned an error trying to load the image? Corrupted Image (I can read these simple gif files in several editors (IrFanView, Photoshop, Windows) and I've tried png files as well..
I've also tried to tell it to use White (which isn't in the image) as a transparent color - as I really would like the black pixels to be considered in the check.. However, that didn't seem to help, and in some cases caused other working stuff to blow up. (Errornumber 2)
What I'd give to have a debugger attached to it...
-Chert _________________ ---
http://www.traderhut.com |
|
| Back to top |
|
 |
Traderhut
Joined: 05 Apr 2008 Posts: 8 Location: DFW
|
Posted: Sun Apr 06, 2008 5:27 am Post subject: Some times you feel like a nut.... |
|
|
SORRY, MY Fault...
My wrapper function did this:
ImageSearch FoundX,FoundY,x,y,x+width,x+height, c:\images\%image%.gif
Not, what I said in the original message.... The 2nd x should have been a y when specifying the 2nd point... No wonder it was screwy...
Things are working well now...
-Chert _________________ ---
http://www.traderhut.com |
|
| Back to top |
|
 |
Traderhut
Joined: 05 Apr 2008 Posts: 8 Location: DFW
|
Posted: Sun Apr 06, 2008 5:47 am Post subject: Not completely... |
|
|
Actually, it is still flaky...
If I pass 0,0,500,500 into it it pukes with ErrorLevel 2 as well..
I'm wondering if it is failing because the stupid machine is in 16 bit color depth, and the bmp is 24 bit, and the gif is a pallete of 256...
(No, I can't change to 24 bit on this stupid machine, heck, I can't even lower it!)
But it works sometimes... Off and on...
-Chert _________________ ---
http://www.traderhut.com |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2364 Location: Australia, Qld
|
Posted: Sun Apr 06, 2008 6:16 am Post subject: |
|
|
| the manual wrote: | *n (variation): Specify for n a number between 0 and 255 (inclusive) to indicate the allowed number of shades of variation in either direction for the intensity of the red, green, and blue components of each pixel's color. For example, *2 would allow two shades of variation. This parameter is helpful if the coloring of the image varies slightly or if ImageFile uses a format such as GIF or JPG that does not accurately represent an image on the screen. If you specify 255 shades of variation, all colors will match. The default is 0 shades.
| If the colours don't match accurately and that prevents ImageSearch from finding the image, it is not being "flaky", but too accurate... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|