AutoHotkey Community

It is currently May 26th, 2012, 1:00 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Start and Stop time
PostPosted: January 1st, 2009, 12:16 am 
Would anyone happen to know how to say have a script running at all times, but only be functional between 7AM and 7PM?


Report this post
Top
  
Reply with quote  
 Post subject: Round about method
PostPosted: January 1st, 2009, 7:02 pm 
Offline

Joined: July 18th, 2007, 5:45 am
Posts: 151
Location: South Florida
Good morning!

How about this:

You have your program running all the time...
[1] Create a script that will terminate the program. Run this from Windows Scheduler at 7PM.
[2] Use the Windows scheduler to start your program at 7AM.
[3] Write a time-check routine to be done at bootup to determine if the program should be run or not. (Otherwise when you boot, your program won't run again until 7AM, even if booted at 7:01 AM)

Don't make things more complicated than they need to be and don't re-invent the wheel.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2009, 10:52 pm 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
Code:
FormatTime, date, HH24 ; get the time in hours
SetTimer, reload, 20000 ; set a timer to go off every 20 seconds

^t::     ; on T
 if date = > 7 & < 19  ; if between 7am adn 7pm
{
;your script here 
}
Return

reload:   ; timer Lable
FormatTime, date, HH24  ; resets the time
return,

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2009, 10:54 pm 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
Instead of FormatTime on a timer, you can simply use the built in variable A_Hour. Also, that if statement needs help :wink:
Code:
^t::     ; ctrl + T
if A_Hour between 7 and 19  ; if between 7am and 7pm
{
;your script here
}
Return

_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2009, 11:10 pm 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
ah yes i forgot about that one. Saves some work

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 1:20 am 
I'm not too sure if that's working, my code is as follows (it's on a loop):

if A_Hour between 7 and 19 ; if between 7am and 7pm
{

Loop {

*Code*

}

}
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 1:54 am 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
Quote:
I'm not too sure if that's working, my code is as follows (it's on a loop):

if A_Hour between 7 and 19 ; if between 7am and 7pm
{

Loop {

*Code*

}

}
Return

Of course not.

Code:
if A_Hour between 7 and 19 ; if between 7am and 7pm
{

Loop {

*Code*

}

}


it's only checking the time once. Put the IF comand in the loop.

Code:
Loop {
if A_Hour between 7 and 19 ; if between 7am and 7pm
 {

 *Code*

  }

}

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 2:06 am 
Oops, thanks :oops:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 4:48 am 
Offline

Joined: December 31st, 2008, 7:30 am
Posts: 23
SpiderGames wrote:
Code:
Loop {
if A_Hour between 7 and 19 ; if between 7am and 7pm
 {

 *Code*

  }

}


What a horrible way of coding; Never use infinite loops..

Code:
SetTimer, Time, 15000 ; Check every 15 seconds

Time:
If A_Hour Between 7 And 19
{
   ; Your code here
}

_________________
Ask stupid questions, get stupid answers.
Search before posting!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 6:50 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Your a bit over critical. Last time I checked that timer is infinate too.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 6:53 am 
Offline

Joined: December 31st, 2008, 7:30 am
Posts: 23
With a delay =\

_________________
Ask stupid questions, get stupid answers.
Search before posting!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 6:53 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
True...

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2009, 5:33 pm 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
personaly I would have it check the time in a loop outside this loop then if that time is correct start loop with an IF comand and a sleep.


But to keep it simple i just took his code, and made it work.

_________________
Image
I know i have 6 legs. It's cuz I'm special.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Exabot [Bot], Google [Bot], Maestr0, poserpro and 14 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