How to link script to time, for example, when it's 11:01 A.M.
Send, something
link script to time
-
- Posts: 90
- Joined: 01 Feb 2021, 03:45
Re: link script to time
Code: Select all
F1::
FormatTime, FormattedTime, % A_Now, hh:mm:ss tt
Send, % FormattedTime
Return
Re: link script to time
You can use the Windows Task Scheduler to run a script at a particular time.
Program = full path to AutoHotkey.exe
Arguments = full path to your script file
Program = full path to AutoHotkey.exe
Arguments = full path to your script file
Re: link script to time
Hallo,
If something should be sent at several specific times of the day:
If something should be sent at several specific times of the day:
Code: Select all
#Persistent
DoIt:
IF DoIt
{
FormatTime, FormattedTime, % A_Now, hh:mm:ss tt
Send, % FormattedTime
}
FormatTime, Now,, HHmmss
For all, Time in [0908,1101,1345,1540] ;HHmm
{
IF (Now > Time .= "00") Or (Time = OldTime)
Continue
DoIt := "20010101" OldTime := Time
DoIt -= "20010101" Now, Seconds
SetTimer, DoIt,% -Max(DoIt,1)*1000
Break
}
Return
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: link script to time
@Rohwedder
Try this:
Try this:
Code: Select all
#Persistent
DoIt:
IF DoIt
{
FormatTime, FormattedTime, % A_Now, hh:mm:ss tt
Send, % FormattedTime
}
FormatTime, Now,, HHmmss
For all, Time in [0001] ;HHmm
{
IF (Now > Time .= "00") Or (Time = OldTime)
Continue
MsgBox, % DoIt := "20010101" OldTime := Time
DoIt -= "20010101" Now, Seconds
MsgBox, % DoIt
SetTimer, DoIt,% -Max(DoIt,1)*1000
Break
}
MsgBox, Wtf?
Return
Re: link script to time
Then perhaps?:
Code: Select all
#Persistent
DoIt:
IF DoIt
{
FormatTime, FormattedTime,% A_Now, hh:mm:ss tt
Send, % FormattedTime
}
FormatTime, Now,, HHmmss
Loop
{
Day := A_Index
For all, Time in [0908,1101,1345,1540] ;HHmm
{
DoIt := "2001010" Day Format("{:04}", Time)
DoIt -= "20010101" Now, Seconds
IF DoIt > 1
Break, 2
}
}
SetTimer, DoIt,% -DoIt*1000
Return
-
- Posts: 90
- Joined: 01 Feb 2021, 03:45
Re: link script to time
I don't want it Send, % FormattedTimeSmile_ wrote: ↑02 May 2021, 04:58Code: Select all
F1:: FormatTime, FormattedTime, % A_Now, hh:mm:ss tt Send, % FormattedTime Return
but I want if FormattedTime = 11:40 P.m.
send, {Enter}
Re: link script to time
Try:
or:
Code: Select all
#Persistent
DoIt:
IF DoIt
Send, {Enter}
FormatTime, Now,, HHmmss
Loop
{
Day := A_Index
For all, Time in [2340] ; HHmm, 2340 = 11:40 P.m.
{
DoIt := "2001010" Day Format("{:04}", Time)
DoIt -= "20010101" Now, Seconds
IF DoIt > 1
Break, 2
}
}
SetTimer, DoIt,% -DoIt*1000
Return
Code: Select all
#Persistent
DoIt:
SetTimer, Doit, 1000
IF (A_Hour A_Min <> "2340") ;HHmm, 2340 = 11:40 P.m.
Return
Send, {Enter}
SetTimer, Doit, 60050
Return
Re: link script to time
Hema Elkady wrote: ↑02 May 2021, 10:48I don't want it Send, % FormattedTime
but I want if FormattedTime = 11:40 P.m.
send, {Enter}
If you're asking how to execute a script at a specific time automatically, Rohwedder's most recent reply is the best answer.
Rohwedder wrote: ↑02 May 2021, 10:57Try:
Code: Select all
#Persistent DoIt: SetTimer, Doit, 1000 IF (A_Hour A_Min <> "2340") ;HHmm, 2340 = 11:40 P.m. Return Send, {Enter} SetTimer, Doit, 60050 Return
Re: link script to time
Hi Rohwedder, I have a similar question. I have a script that I would like to launch every Thursday at 10:30 am. Using your example, I am able to launch it at the desired time.Rohwedder wrote: ↑02 May 2021, 10:57Code: Select all
#Persistent DoIt: SetTimer, Doit, 1000 IF (A_Hour A_Min <> "2340") ;HHmm, 2340 = 11:40 P.m. Return Send, {Enter} SetTimer, Doit, 60050 Return
Is there a way to make it launch on Thursdays only?
Re: link script to time
Then perhaps:But, there are definitely better methods!
Code: Select all
#Persistent
DoIt:
SetTimer, Doit, 1000
IF (A_WDay A_Hour A_Min <> "51030") ;WdayHHmm, Thursday at 10:30 am
Return ;Wday = Current 1-digit day of the week (1-7). 1 is Sunday
Send, {Enter}
SetTimer, Doit, 60050
Return
Re: link script to time
There might be better methods but for my simple home use, this will do just fine. Thank you!Rohwedder wrote: ↑06 May 2021, 09:24Then perhaps:But, there are definitely better methods!Code: Select all
#Persistent DoIt: SetTimer, Doit, 1000 IF (A_WDay A_Hour A_Min <> "51030") ;WdayHHmm, Thursday at 10:30 am Return ;Wday = Current 1-digit day of the week (1-7). 1 is Sunday Send, {Enter} SetTimer, Doit, 60050 Return