 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Thu Feb 22, 2007 8:17 pm Post subject: Return causes delay |
|
|
Hi this script is working but the return is delaying the color search
id like the script to popup the msgbox the instant the color isnt white.
basicly I just want to send space every two seconds and while doing that
check under the cursor for white or not white without a delay
Im sure there is a better way to do this but im new to this and this is what
I came up with thanks for your help
| Code: |
#Persistent
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Main:
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
IfEqual, color, 0xFFFFFF
{
SetTimer,Doit,2000
}
Else
{
msgbox, No white found
}
Return
Doit:
Send {Space}
goto, Main
LShift::Pause |
|
|
| Back to top |
|
 |
NiJo
Joined: 12 Nov 2005 Posts: 73
|
Posted: Thu Feb 22, 2007 8:24 pm Post subject: |
|
|
Your script is only checking the color right after the space send, 2 in 2 seconds...
This should work
| Code: | #Persistent
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTimer,Doit,2000
loop
{
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
IfNotEqual, color, 0xFFFFFF
{
SetTimer, Doit, Off ; Don't know if you want to stop it...
msgbox, No white found
SetTimer, Doit, On ; ... if you want delete this line.
}
sleep, 100 ; I think you don't need that Instant-ness... if Yes delete this line
}
Return
Doit:
Send {Space}
return
LShift::Pause |
|
|
| Back to top |
|
 |
Jaytech
Joined: 11 Dec 2006 Posts: 242 Location: Orlando, FL
|
Posted: Thu Feb 22, 2007 8:29 pm Post subject: |
|
|
A bit simplier, and should be faster.
| Code: | #Persistent
#NoEnv
SendMode Input
SetBatchLines -1
F6:: ;Press F6 to start
Loop
{
MouseGetPos MouseX, MouseY
PixelGetColor X, %MouseX%, %MouseY%
IfEqual X, 0xFFFFFF
Send {Space}
Else
msgbox No white found
}
Return
LShift::Pause |
I usually make an "out" as well (something to break the loop). But since you are not using the mouse in this script, you should be able to simply right click the tray icon and exit. |
|
| Back to top |
|
 |
NiJo
Joined: 12 Nov 2005 Posts: 73
|
Posted: Thu Feb 22, 2007 8:32 pm Post subject: Re: Return causes delay |
|
|
@Jaytech: | Anonymous wrote: | | I just want to send space every two seconds and while doing that... |
 |
|
| Back to top |
|
 |
Guest_ Guest
|
Posted: Thu Feb 22, 2007 8:34 pm Post subject: |
|
|
I cam upe with this...
| Code: | #Persistent
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Main:
Loop, 200 {
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
IfEqual, color, 0xFFFFFF
{
sleep, 10
} Else {
msgbox, % "No white found"
}
}
SetTimer,Doit,1
Return
Doit:
Send {Space}
goto, Main
LShift::Pause |
|
|
| Back to top |
|
 |
NiJo
Joined: 12 Nov 2005 Posts: 73
|
Posted: Thu Feb 22, 2007 8:38 pm Post subject: |
|
|
I don't recommend you use that code...
It only loops for 200 times apparently, but the Threads are all messed up! Your calling the DoiIt every 1ms, that causes the script to actually launch it after 15ms or 1000lines because of threads default interruptibility value.
I do not recommend you use a settimer with 1ms repeat time and making it call a loop... There are other cleaner ways...
And don't even try putting setBatchLines -1 there or your PC will become a toaster 
Last edited by NiJo on Thu Feb 22, 2007 8:39 pm; edited 1 time in total |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Feb 22, 2007 8:39 pm Post subject: thanks |
|
|
that has to be a record for response time:)
thanks for your replies
Nijo that was just what i was looking for
ill try the others out too i just wanted to get this post in didnt know this forum
went that quick lol. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Feb 22, 2007 8:51 pm Post subject: |
|
|
ok tried em all Jaytech thanks but i think you misread lol i am using the F6
to start though
guest_ thanks but i needed an infinite loop. |
|
| 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
|