I would like to make my scrip expire after a specific date. I can't seem to get this working. All help is appreciated
For example.....
Code: Select all
expireDate = 20181025
if (a_now > ExpireDate)
{
Msgbox, Expired!
Exitapp
}
Code: Select all
expireDate = 20181025
if (a_now > ExpireDate)
{
Msgbox, Expired!
Exitapp
}
This does help for the format of the expiration date. However the entire code still isn't workingNextron wrote: ↑26 Oct 2018, 08:32This should help: https://autohotkey.com/docs/commands/Fi ... m#YYYYMMDD
Code: Select all
FileSetTime, 20181025
expireDate = 20181025
if (a_now > ExpireDate)
{
Msgbox, Expired!
Exitapp
}
Code: Select all
expireDate = 20181025
EnvSub,expireDate,% A_Now,D
If (expireDate<0)
MsgBox Expired
Code: Select all
expireDate = 20181025000000
if (a_now > ExpireDate)
{
Msgbox, Expired!
Exitapp
}
Nextron wrote: ↑26 Oct 2018, 08:56FileSetTime isn't needed. I tried to point you to the format of A_Now which is YYYYMMDDHH24MISS and not YYYYMMDD. You can compare different date formats if you make clear it are dates. Right now you're comparing a huge number versus a much smaller number.
Code: Select all
expireDate = 20181025 EnvSub,expireDate,% A_Now,D If (expireDate<0) MsgBox Expired
Code: Select all
^J::
send, test
return
expireDate = 20181025
EnvSub,expireDate,% A_Now,D
If (expireDate<0)
MsgBox Expired
Code: Select all
#SingleInstance, Force
ExpireDate := "20181027"
CurrentDate := SubStr(A_Now, 1, 8)
If (CurrentDate >= ExpireDate) {
MsgBox, Expired!
ExitApp
}
MsgBox, Not Expired!
Code: Select all
#SingleInstance, Force
ExpireDate := "20181027"
CurrentDate := SubStr(A_Now, 1, 8)
^J::
If (CurrentDate >= ExpireDate) {
MsgBox, Expired
} Else {
Send, Test
}
return
Code: Select all
#SingleInstance, Force
ExpireDate := "20181025"
CurrentDate := (A_Now)
If (CurrentDate >= ExpireDate)
ExitApp
SirSocks wrote: ↑26 Oct 2018, 13:08I think we're getting closer. I am now fiddling around with this script, and still have no luck. Just trying to get the .exe to exit after a specific date.
I am still looking for any other advice.Code: Select all
#SingleInstance, Force ExpireDate := "20181025" CurrentDate := (A_Now) If (CurrentDate >= ExpireDate) ExitApp
Thank you!
Code: Select all
#SingleInstance, Force
ExpireDate := "20181023"
CurrentDate := SubStr(A_Now, 1, 8)
If (CurrentDate >= ExpireDate) {
ExitApp
}
MsgBox, Not Expired!
I think what you are after is a timer. Do you want it to regularly keep checking the date? This code will only perform one check at the start of the script and then it will never check again.SirSocks wrote: ↑26 Oct 2018, 13:08I think we're getting closer. I am now fiddling around with this script, and still have no luck. Just trying to get the .exe to exit after a specific date.
I am still looking for any other advice.Code: Select all
#SingleInstance, Force ExpireDate := "20181025" CurrentDate := (A_Now) If (CurrentDate >= ExpireDate) ExitApp
Thank you!
Code: Select all
#SingleInstance, Force
ExpireDate := "20181025"
SetTimer, CheckExpire, 30000
return
CheckExpire:
If (A_Now >= ExpireDate)
ExitApp
return
I already posted a working solution based on your example. What is your complaint regarding this code?Code: Select all
#SingleInstance, Force ExpireDate := "20181023" CurrentDate := SubStr(A_Now, 1, 8) If (CurrentDate >= ExpireDate) { ExitApp } MsgBox, Not Expired!
Users browsing this forum: filipemb and 300 guests