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 

Terminate at X time

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



Joined: 18 Jul 2008
Posts: 3

PostPosted: Fri Jul 18, 2008 7:56 pm    Post subject: Terminate at X time Reply with quote

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
View user's profile Send private message
G_uest
Guest





PostPosted: Fri Jul 18, 2008 8:06 pm    Post subject: Reply with quote

Code:

if (A_Hour >= 06 and A_Min >=45)
 break
Back to top
jaco0646



Joined: 07 Oct 2006
Posts: 559
Location: MN, USA

PostPosted: Fri Jul 18, 2008 8:14 pm    Post subject: Reply with quote

If you meant 6:45 PM, the hour will be 18 instead of 06.
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
G_uest
Guest





PostPosted: Fri Jul 18, 2008 8:24 pm    Post subject: Reply with quote

Also:

Code:

If ( SubStr(A_Now,9,4) = 0645 )
 break
Back to top
G_uest
Guest





PostPosted: Fri Jul 18, 2008 8:25 pm    Post subject: Reply with quote

make that a ">=" on my last post instead of "="
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 10:41 pm    Post subject: Re: Terminate at X time Reply with quote

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


Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Jul 18, 2008 11:09 pm    Post subject: Re: Terminate at X time Reply with quote

SKAN wrote:


Code:
If ( SubStr( A_Now,9,4 ) >= "0645" ) ; 06:45 Hrs
Break


Smile


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

PostPosted: Fri Jul 18, 2008 11:15 pm    Post subject: Re: Terminate at X time Reply with quote

Anonymous wrote:
I found a fatal flaw...

      Very Happy


following would be better:

Code:
Time := SubStr( A_Now 9,4 )
If ( Time >= "0645" AND Time <= "0655" )
  Break


Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Jul 18, 2008 11:18 pm    Post subject: Reply with quote

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

PostPosted: Sat Jul 19, 2008 12:01 am    Post subject: Reply with quote

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
View user's profile Send private message
toxicvega



Joined: 18 Jul 2008
Posts: 3

PostPosted: Sat Jul 19, 2008 1:49 am    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Sat Jul 19, 2008 6:42 am    Post subject: Reply with quote

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

Smile
_________________
SKAN - Suresh Kumar A N
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