AutoHotkey Community

It is currently May 27th, 2012, 10:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: July 16th, 2007, 4:31 am 
Offline

Joined: July 15th, 2007, 3:39 am
Posts: 6
wantedColor = 0xFFFFFF
crossX = 40
crossY = 78
Loop
{
PixelGetColor, notepadColor, %crossX%, %crossY%
if %ErrorLevel% = 0
Sendplay hello
sleep 200
}


This is a script I found that will send "hello" repeatedly whenever a pixel at the specified coordinates are the correct color. I'd like the script to work so that once the correct color is detected the script sends "hello" only once, instead of looping it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2007, 7:24 am 
Offline

Joined: March 15th, 2007, 4:10 am
Posts: 70
Code:
wantedColor = 0xFFFFFF
crossX = 40
crossY = 78
Loop
{
PixelGetColor, notepadColor, %crossX%, %crossY%
if %ErrorLevel% = 0
Sendplay hello
sleep 200
}


I think this should work...untested

Code:
msgSentOnce = 0
wantedColor = 0xFFFFFF
crossX = 40
crossY = 78
SetTimer, isColorThere, 1000

isColorThere:
    if msgSentOnce
        Return
    PixelGetColor, notepadColor, %crossX%, %crossY%
    if ! ErrorLevel
    {
        Sendplay hello
        msgSentOnce = 1
    }
Return


You could also take out the msgSentOnce variable references and change
Code:
msgSentOnce = 1
to
Code:
SetTimer, isColorThere, off

It just depends on what you're trying to do if the color is found.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2007, 6:16 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
a simple adjustment to your code, (though the other reply looks more useful)
Code:
wantedColor = 0xFFFFFF
crossX = 40
crossY = 78
Loop
{
  PixelGetColor, notepadColor, %crossX%, %crossY%
  if %ErrorLevel% = 0
    Break
  sleep 200
}
Sendplay hello

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, robotkoer, Yahoo [Bot] and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group