Script checks date and not open on two computers at the same time

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Script checks date and not open on two computers at the same time

27 Mar 2018, 02:20

Hello friends of the community, I am very in need of a script that checks the date on a web site before it opens and if possible also does not allow it to open on two computers at the same time.
Is this possible?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Script chacks date and not open on two computers at the same time

27 Mar 2018, 05:13

What's the background story/context for that event :?:
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Re: Script chacks date and not open on two computers at the same time

27 Mar 2018, 05:45

BoBo wrote:What's the background story/context for that event :?:

I want to sell the scripts, however I want to sell for a period of use, for example 3 months, I could put the date that it will end up fixed inside the code, however the script has to check if the date has already passed.

could be up to the date of the computer, but it would be easy to circumvent the script so it would never end the deadline, so I would check in a place where there is no way to circumvent the system.
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 09:48

You aren't going to have much luck with reasonably competent users, since basically anyone who knows what they are doing could decompile the script and remove your timer from it. DRM is hard, especially when you are talking about a program that was never designed to support it.
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 11:12

MaxAstro wrote:You aren't going to have much luck with reasonably competent users, since basically anyone who knows what they are doing could decompile the script and remove your timer from it. DRM is hard, especially when you are talking about a program that was never designed to support it.


I understand, but would someone like to show an example of how to check the date on an official date and time site?
I will prepare myself for this as neither the best servers in the world are safe from haker and malicious people, but most do not have this knowledge of how to decompile the file.
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 12:52

Using info I got from this thread: https://autohotkey.com/boards/viewtopic.php?t=6547

I came up with this example which should always give the current date no matter what the user has their computer set to:

Code: Select all

timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, MM/dd/yyyy
MsgBox,, Real Date,  %RealDate%
It saves a temp file and then deletes it, hopefully that won't be an issue.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 13:00

You can try also:

Code: Select all

MsgBox, % GetUTC()

GetUTC() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.timeanddate.com/worldclock/timezone/utc")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, "s).+id=ct class=h1>(.+?)</span>.+?id=ctdat>(.+?)</span>.+", "$1`n$2")
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 20:41

Odlanir wrote:You can try also:

Code: Select all

MsgBox, % GetUTC()

GetUTC() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.timeanddate.com/worldclock/timezone/utc")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, "s).+id=ct class=h1>(.+?)</span>.+?id=ctdat>(.+?)</span>.+", "$1`n$2")
}

Thanks for the code, only detail is that I can not create a variable with the same information so I can compare the dates, for example

if the date is greater than 04/27/2018 do not open the program

that noc would be like a one-month license.

could you help me in this?
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Re: Script checks date and not open on two computers at the same time

27 Mar 2018, 21:02

Nightwolf85 wrote:Using info I got from this thread: https://autohotkey.com/boards/viewtopic.php?t=6547

I came up with this example which should always give the current date no matter what the user has their computer set to:

Code: Select all

timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, MM/dd/yyyy
MsgBox,, Real Date,  %RealDate%
It saves a temp file and then deletes it, hopefully that won't be an issue.

Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)

Code: Select all


DateExpired := 27/03/2018, S
FormatTime, DateExpired, 
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, dd/MM/yyyy
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Script checks date and not open on two computers at the same time

28 Mar 2018, 08:05

zanusso wrote:Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)
I think if you format the time like this it works as you describe?

Code: Select all

DateExpired := 20180327
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide ; What if this fails? should check it.
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
; This is where I would check if the variable Time has a valid ntp query.
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, yyyyMMdd
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program
Edit: One issue I can't help with is I don't know what happens if getting the time offset can't connect. You could test and see if the output matches a successful query instead of assuming it does.
zanusso
Posts: 19
Joined: 23 Mar 2018, 17:49

Re: Script checks date and not open on two computers at the same time

28 Mar 2018, 11:28

Nightwolf85 wrote:
zanusso wrote:Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)
I think if you format the time like this it works as you describe?

Code: Select all

DateExpired := 20180327
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide ; What if this fails? should check it.
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
; This is where I would check if the variable Time has a valid ntp query.
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, yyyyMMdd
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program
Edit: One issue I can't help with is I don't know what happens if getting the time offset can't connect. You could test and see if the output matches a successful query instead of assuming it does.


Friend, actually if you do not have a static connection picking up a local time, where it's failing to verify

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Panaku, Rohwedder, roysubs and 316 guests