 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
toxicvega
Joined: 18 Jul 2008 Posts: 3
|
Posted: Fri Jul 18, 2008 7:56 pm Post subject: Terminate at X time |
|
|
I have searched the forum as well as anyone can and have found several threads, but I still haven't figured out how to implement the code.
As it stands I have a simple code written with the Auto Script writer (all I need it to do is point and click a couple times) I have the macro run on a loop.
I have seen the threads about DLLcall and still I cant get it to kill its self.
| Code: | Loop
{
WinWaitActive, XXX program
MouseClick, left, 88, 36
Sleep,100
WinWait, XXX program
IfWinNotActive, XXX program
WinWaitActive, XXX program
MouseClick, left, 253, 96
Sleep, 100
WinWait, XXX program
IfWinNotActive, XXX program
WinWaitActive, XXX Progran
MouseClick, left, 236, 38
Sleep, 100
}
|
I have tried to insert this code, but it doesn't do anything
| Code: | If ( SubStr( A_Now DllCall( "Sleep", UInt,1000 ),9,4 ) = "0645" )
Exit |
What I need this script to do, is check either at the begining or end of the script if the time is >=0645 and terminate itself. |
|
| Back to top |
|
 |
G_uest Guest
|
Posted: Fri Jul 18, 2008 8:06 pm Post subject: |
|
|
| Code: |
if (A_Hour >= 06 and A_Min >=45)
break
|
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 559 Location: MN, USA
|
|
| Back to top |
|
 |
G_uest Guest
|
Posted: Fri Jul 18, 2008 8:24 pm Post subject: |
|
|
Also:
| Code: |
If ( SubStr(A_Now,9,4) = 0645 )
break
|
|
|
| Back to top |
|
 |
G_uest Guest
|
Posted: Fri Jul 18, 2008 8:25 pm Post subject: |
|
|
| make that a ">=" on my last post instead of "=" |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Fri Jul 18, 2008 10:41 pm Post subject: Re: Terminate at X time |
|
|
| toxicvega wrote: | I have tried to insert this code, but it doesn't do anything
| Code: | If ( SubStr( A_Now DllCall( "Sleep", UInt,1000 ),9,4 ) = "0645" )
Exit |
What I need this script to do, is check either at the begining or end of the script if the time is >=0645 and terminate itself. |
Your loop already sleeps 300ms, so you can remove that additional sleep from that/my code
| Code: | If ( SubStr( A_Now,9,4 ) >= "0645" ) ; 06:45 Hrs
Break |
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jul 18, 2008 11:09 pm Post subject: Re: Terminate at X time |
|
|
| SKAN wrote: |
| Code: | If ( SubStr( A_Now,9,4 ) >= "0645" ) ; 06:45 Hrs
Break |
 |
Ok, Thats perfect, however, I found a fatal flaw...
If I try to run the script again i.e. after it breaks, It runs once due to the >= code. Is there a way to instead to set a range say
| Code: | If ( SubStr( A_Now 9,4 ) >= "0645" and <= "0655" )
Exit |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Fri Jul 18, 2008 11:15 pm Post subject: Re: Terminate at X time |
|
|
| Anonymous wrote: | | I found a fatal flaw... |
following would be better:
| Code: | Time := SubStr( A_Now 9,4 )
If ( Time >= "0645" AND Time <= "0655" )
Break |
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jul 18, 2008 11:18 pm Post subject: |
|
|
| so, u want it to stop for ten minute, that is: stop between 0645 and 0655? |
|
| Back to top |
|
 |
toxicvega
Joined: 18 Jul 2008 Posts: 3
|
Posted: Sat Jul 19, 2008 12:01 am Post subject: |
|
|
| Anonymous wrote: | | so, u want it to stop for ten minute, that is: stop between 0645 and 0655? |
What I really want, is if the loop resarts between X and Y time I want it to goto a sub. This is what I have got to so far
| Code: |
Loop
If ( SubStr ( A_Now,9,4 ) >= "1852" And Time <= "1915" )
gosub, done
{ my script
}
done:
msgbox DONE
ExitApp
esc::
ExitApp
return
|
The Problem I am facing now is It either goes straight to the Sub, or ignores it completely.
The times are just for testing only, thats why they reflect somewhat current times locally |
|
| Back to top |
|
 |
toxicvega
Joined: 18 Jul 2008 Posts: 3
|
Posted: Sat Jul 19, 2008 1:49 am Post subject: |
|
|
Still despiratly need help.
It doesn't really matter how I format the snippet of code, it still either go to the sub or it skips it completely |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Sat Jul 19, 2008 6:42 am Post subject: |
|
|
| toxicvega wrote: | | It doesn't really matter how I format the snippet of code, it still either go to the sub or it skips it completely |
try my tested code without altering anything ( except time ) ..
| Code: | Loop {
If ( SubStr( A_Now,9,4 ) >= "1039" And SubStr( A_Now,9,4 ) <= "1040" )
GoSub, Done
; Rest of your code goes here
Sleep 500
Tooltip %A_Now%
}
Return
Done:
MsgBox DONE
ExitApp |
So, what was wrong with your snippet ?:
| Code: | Loop
If ( SubStr ( A_Now,9,4 ) >= "1852" And Time <= "1915" )
gosub, done
{ my script
}
done:
msgbox DONE
ExitApp
esc::
ExitApp
return |
1) Loop braces are incorrect ..
2) Time var is never initialised
3) never ever leave a space between a function name and the open parentheses
 _________________ SKAN - Suresh Kumar A N |
|
| 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
|