 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Crusader
Joined: 28 Jan 2007 Posts: 42
|
Posted: Fri Jun 13, 2008 12:41 am Post subject: help with pixel search |
|
|
I need help writing my code... i need to write a program that when a certain pixel(specified in code below) turns white is sends "send, #p" and when i click the windows key+s is sends #p again.... once this process is complete, it restarts searching for the white pixel. here is my code, can someone please tell me what i did wrong?
| Code: | #a::
loop
{
loop
{
PixelSearch, Px, Py, 276, 231, 278, 233, FFFFFF, 0, Fast
}
sleep, 100
send, #P
#s::
sleep, 100
send, #p
}
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jun 13, 2008 1:08 am Post subject: |
|
|
| you can't put hotkey:: inside brackets |
|
| Back to top |
|
 |
Crusader
Joined: 28 Jan 2007 Posts: 42
|
Posted: Fri Jun 13, 2008 4:27 am Post subject: |
|
|
| besides that, what else is wrong?..... can someone please fix what is wrong really quickly, thank you |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Fri Jun 13, 2008 4:40 am Post subject: |
|
|
| Code: |
#a::
next = 0
loop
{
PixelSearch, Px, Py, 276, 231, 278, 233, FFFFFF, 0, Fast
if (Px)
break
}
sleep, 100
send, #P
loop
if (next)
break
sleep, 100
send, #p
return
#s::
next = 1
return
|
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1495
|
Posted: Fri Jun 13, 2008 7:35 am Post subject: |
|
|
| Code: | #a::SetTimer, WatchForAPixel, 100
WatchForAPixel:
loop
{
PixelSearch, Px, Py, 276, 231, 278, 233, FFFFFF, 0, Fast
If (ErrorLevel)
Sleep 10
Else
Break
}
sleep, 100
send, #P
Win_S_flag := 0
Loop
{
If (Win_S_flag = 0)
sleep 10
else
break
}
sleep, 100
send, #p
return
#p::Win_S_flag := 1 | untested _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
Crusader
Joined: 28 Jan 2007 Posts: 42
|
Posted: Fri Jun 13, 2008 8:06 pm Post subject: |
|
|
| ok, thanks guys, ill try these out when i get home. I really appreciate your help. |
|
| Back to top |
|
 |
Crusader
Joined: 28 Jan 2007 Posts: 42
|
Posted: Sat Jun 14, 2008 4:58 am Post subject: |
|
|
| hmmmm.... im afraid neither of these work for me... do you think something is wrong with my computer? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1495
|
Posted: Sat Jun 14, 2008 6:33 am Post subject: |
|
|
| Code: | #a::SetTimer, WatchForAPixel, 100
WatchForAPixel:
loop
{
PixelSearch, Px, Py, 276, 231, 278, 233, 0xFFFFFF, 0, Fast
If (ErrorLevel)
Sleep 10
Else
Break
}
sleep, 100
send, #P
Win_S_flag := 0
Loop
{
If (Win_S_flag = 0)
sleep 10
else
break
}
sleep, 100
send, #p
return
#p::Win_S_flag := 1 | oops _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
Crusader
Joined: 28 Jan 2007 Posts: 42
|
Posted: Sat Jun 14, 2008 8:36 pm Post subject: |
|
|
| man.... this code doesn't work for me either, if you need to, you could make it as simple as... when that pixel turns white, it presses #p then exits out of the application....just as long as THAT works! thanks... |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1495
|
Posted: Sat Jun 14, 2008 10:22 pm Post subject: |
|
|
maybe you don't ever have a white pixel for the code to detect Try having the pixel search loop display a tooltip with the found XY and errorlevel.
Just saying that code "doesn't work" won't help anyone trying to help you. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Jun 14, 2008 10:23 pm Post subject: |
|
|
| no matter what i try, when there is an error, (FFFFFF is not found) it still breaks the loop. what can i do to fix this? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1495
|
Posted: Sat Jun 14, 2008 10:34 pm Post subject: |
|
|
Maybe you're missing Coordmode, pixel, screen above the pixelsearch, but it's anyone's guess....
btw: the "0x" needs to be in front of "FFFFFF" to even have a chance of working. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jun 15, 2008 2:42 am Post subject: |
|
|
| i found an alternative way to do this...is there a way to pixelsearch, while doing something else, like while surfing the net, and have the script search a minimised window? |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sun Jun 15, 2008 5:55 am Post subject: |
|
|
| Nope, PixelSearch only sees what you see. |
|
| 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
|