If Time Since Login

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

If Time Since Login

Post by hemsith14_ » 22 Jan 2022, 13:01

Hey, is it possible to determine time since login like "A_TickCount"?

I want to use it like:

Code: Select all

If (A_TickCount <= 10000); but since login, not since startup
do something
Thanks!

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: If Time Since Login

Post by mikeyww » 22 Jan 2022, 13:06

If you run a startup script, you can store the tick count in an INI file.

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: If Time Since Login

Post by hemsith14_ » 22 Jan 2022, 13:08

But I want to use it as time since login, not since startup

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: If Time Since Login

Post by mikeyww » 22 Jan 2022, 13:17

Startup scripts run at login if placed in a startup directory.

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: If Time Since Login

Post by hemsith14_ » 22 Jan 2022, 13:33

Yea, but I want it to do something only if no more than 10 seconds have passed since login.

like:
If (Time since login <= 10000)
do something

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: If Time Since Login

Post by mikeyww » 22 Jan 2022, 13:36

Store the tick count at login. You can then retrieve it, and compare it to the current count.

Code: Select all

login := A_TickCount
F3::
If (A_TickCount - login < 10000)
     MsgBox, 64, Status, Good
Else MsgBox, 48, Status, Bad
Return

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: If Time Since Login

Post by hemsith14_ » 22 Jan 2022, 13:50

So in this

Code: Select all

login := A_TickCount
F3::
If (A_TickCount - login < 10000)
     MsgBox, 64, Status, Good
Else MsgBox, 48, Status, Bad
Return
The "good" msgbox will appear only if the time that passed since login is less than 10 seconds?

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: If Time Since Login

Post by mikeyww » 22 Jan 2022, 14:17

Yes, but you need not take my word for it. Give it a go!

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: If Time Since Login

Post by hemsith14_ » 22 Jan 2022, 17:54

It's not working :(

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: If Time Since Login

Post by mikeyww » 22 Jan 2022, 18:24

You can display the login tick count and also the tick count upon the hotkey. Post your revised script. What happened when you put a LNK shortcut to the script into your startup directory, and it ran? What should happen instead? Did the script run? If not, then what was the command line in your startup shortcut?

Post Reply

Return to “Ask for Help (v1)”