AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PixelSearch Help

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
samalcorn
Guest





PostPosted: Tue May 20, 2008 1:25 am    Post subject: PixelSearch Help Reply with quote

I am running a game, full screen, and am trying to find a specific color in a defined area.

Below is the script I have to search for the color.

I am assuming that the AutoHotKey help file is correct and I'm using 255,118 as the upper left corner of the search area and 689, 596 as the lower right corner.

The script NEVER finds the specified color when searching the defined area unless I place the mouse pointer on the color. It is not finding the mouse pointer Smile. I can place the mouse anywhere within the search box and it doesn't find it, it only finds the color if I place the tip of the mouse pointer on the color.

Both AutoIt3 and AHK Window Info give me the same color information so I know that I'm looking for the right color.

Why won't this script find the specified color within the specified search box?

Quote:
WinWaitActive, XXXXXX,
send ^p::pause


CoordMode, PIXEL, SCREEN
CoordMode, MOUSE, SCREEN

loop
{
pixelsearch,Px,Py,255,118,689,596,0x484800


if ErrorLevel
MsgBox, That color was not found in the specified region.
else
MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%
sleep, 6000
}

return

^p:: pause
Back to top
sinkfaze



Joined: 19 Mar 2008
Posts: 140

PostPosted: Tue May 20, 2008 1:50 am    Post subject: Reply with quote

That's a very large defined area, any way to further constrict the search area and still make it workable in your game?
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
salcorn



Joined: 20 May 2008
Posts: 4

PostPosted: Tue May 20, 2008 2:06 am    Post subject: PixelSearch Help Reply with quote

sinkfaze wrote:
That's a very large defined area, any way to further constrict the search area and still make it workable in your game?


The area is that large because I increased the size during testing. The original search area was 514,366 and 531,381. When that didn't work, I started increasing the size of the search area in an attempt to find out what was happening.

But even with the smaller search are, I was getting the same results, only found the specified color if I hovered the mouse pointer over it.
Back to top
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 140

PostPosted: Tue May 20, 2008 2:38 am    Post subject: Reply with quote

Does this work?

Code:
SetTimer, ColorFind, 1000
return

ColorFind:

PixelSearch, Px, Py, 255, 118, 689, 596, 0x484800, 3, Fast
if ErrorLevel
 MsgBox, That color was not found in the specified region.
else
{
 MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%
 sleep, 6000
}
return

^p::
SetTimer, ColorFind, Off
return


Don't specify any CoordMode settings. Setting the timer to one second will allow time to search a broader area, but it may affect the accuracy of the search with that much time to elapse.
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
salcorn



Joined: 20 May 2008
Posts: 4

PostPosted: Tue May 20, 2008 3:21 am    Post subject: Reply with quote

sinkfaze wrote:
Does this work?

Code:
SetTimer, ColorFind, 1000
return

ColorFind:

PixelSearch, Px, Py, 255, 118, 689, 596, 0x484800, 3, Fast
if ErrorLevel
 MsgBox, That color was not found in the specified region.
else
{
 MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%
 sleep, 6000
}
return

^p::
SetTimer, ColorFind, Off
return


Don't specify any CoordMode settings. Setting the timer to one second will allow time to search a broader area, but it may affect the accuracy of the search with that much time to elapse.


It doesn't run at all. When I save the above as an .ahk file and double click it, I get an "error on line 6" return. The line with first MsgBox command on it.
Back to top
View user's profile Send private message
Guest






PostPosted: Tue May 20, 2008 3:30 am    Post subject: Reply with quote

salcorn wrote:
It doesn't run at all. When I save the above as an .ahk file and double click it, I get an "error on line 6" return. The line with first MsgBox command on it.


it runs here, you fail @ copy & pasting
Back to top
salcorn



Joined: 20 May 2008
Posts: 4

PostPosted: Tue May 20, 2008 3:43 am    Post subject: Reply with quote

Anonymous wrote:
salcorn wrote:
It doesn't run at all. When I save the above as an .ahk file and double click it, I get an "error on line 6" return. The line with first MsgBox command on it.


it runs here, you fail @ copy & pasting


Thanx to your very helpful response.

I, again, copied the given script, pasted it, saved it and tried to re-execute it.

It failed with the same error.
Back to top
View user's profile Send private message
keybored



Joined: 18 Jun 2006
Posts: 90
Location: Phoenix, AZ

PostPosted: Tue May 20, 2008 4:03 am    Post subject: Reply with quote

salcorn it worked for me. Are you running the latest ahk. I can't think of anything else to consider.
Back to top
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 140

PostPosted: Tue May 20, 2008 4:11 am    Post subject: Reply with quote

salcorn wrote:
It doesn't run at all. When I save the above as an .ahk file and double click it, I get an "error on line 6" return. The line with first MsgBox command on it.


If you copied and pasted exactly what I wrote into its own script and added nothing else, line 6 should be the PixelSearch line. Are you running the most current version of AHK?
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
salcorn



Joined: 20 May 2008
Posts: 4

PostPosted: Thu May 22, 2008 12:25 am    Post subject: Reply with quote

sinkfaze wrote:
salcorn wrote:
It doesn't run at all. When I save the above as an .ahk file and double click it, I get an "error on line 6" return. The line with first MsgBox command on it.


If you copied and pasted exactly what I wrote into its own script and added nothing else, line 6 should be the PixelSearch line. Are you running the most current version of AHK?


Sorry about the delay but I do appreciate the help.

I am running AHK 1.0.47.06, just downloaded it last weekend and the home page indicates that this is the most recent version.

I used the "in message" expand and copy function, then I pasted that into a new notepad window. I then saved that as PixelFinder Help.ahk. If I double click that file, I get the following error message:

"Error at line 8.

Line Text: MsgBox, That color was not found in the specified region.
Error: This line does not contain a recognized action.

The program will exit."

The quotes were added by me.

HOWEVER, if I type your suggestion into a new notepad window, the program runs fine.

Am I misunderstanding the correct use of the in message expand and copy function??????


And, finally, your suggested code responds in exactly the same way my orginal code did. It doesn't find a thing unless I hover the mouse pointer over the image.
Back to top
View user's profile Send private message
k3ph



Joined: 21 Jul 2006
Posts: 123

PostPosted: Thu May 22, 2008 1:48 am    Post subject: Reply with quote

salcorn wrote:
I used the "in message" expand and copy function


when my computer is overclocked, my shitty ram memory doesn't supports a very high fsb, so this javascript function pastes the code, filled with many dirty NULL data at the end of the script and sometimes mixtured inside the code.

I guess you use a very shitty text editor like ms notepad and cannot see NULL data huh? I recommend you to get a read editor like scite, notepad++ or anything else to read real characters on it.

As you pasted in the first post of the thread (your own message), this code: selected, copied and pasted, worked flawlessy here, so i guess you are alone.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group