Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Retrieve computer's current time and use it


  • Please log in to reply
5 replies to this topic
arkazal
  • Guests
  • Last active:
  • Joined: --
I'm trying to retrieve the computer's current time and then be able to use it. So, for example, I want to be able to say that if it's 5:03 PM, then this happens. Or, if it's 12:10 AM, this happens. Currently I'm trying to use FormatTime and I just can't understand the help file on it. Hopefully someone can write me a quick script with some message box examples or something so I can see how I can achieve something like this.

  • Guests
  • Last active:
  • Joined: --
Show us what you have tried so that we can see what exactly you are looking for.

arkazal
  • Guests
  • Last active:
  • Joined: --
I haven't really tried anything. I have no idea where to start. The things I've tried haven't even come close to relating to what I want to do.

Basically, I need a command that is able to check what time the computer's clock is at and then open a program. I know how to open a program using AHK, but I don't know how to use the computer's current time. If someone can tell me a command to use the computer's current time, that would be awesome. It's all I'm asking. I hope that what I'm asking isn't more complicated than I think it is :p

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
see <!-- m -->http://l.ahk.me/docs...iables.htm#YYYY<!-- m -->
FormatTime is another way but it will be more complicated. There's also <!-- m -->http://l.ahk.me/docs/Variables.htm#Now<!-- m -->

jpjazzy
  • Members
  • 800 posts
  • Last active: Dec 17 2014 07:22 AM
  • Joined: 16 Feb 2010
SetTimer, GetCompTime, 80

GetCompTime:
FormatTime, MyTime,, hh:mm:ss tt
ToolTip % MyTime
return

Simple one line code to get time:

FormatTime, OutputVar,, Time ; Omits seconds

Use If statements to get what you need out of the time.
AutoHotkey Basic - Windows 7
Posted Image

dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010
I wrote this for fun and thought it might be useful :D :
#noenv
#singleinstance, ignore
#persistent
setbatchlines, 10ms
settimer, emptymem, 600000 ;minimize ram use every 10 minutes.
settimer, time, 500 ;check time every half second.
return

time:
 {
   formattime, time, , h:mm:ss tt ;gets system time and puts it in desired format.
   if (time = "10:30:00 am") ;calls action1 subroutine at specified time.
    {
      goto, action1
    }
   if (time = "10:35:36 am") ;calls action2 subroutine at specified time.
    {
      goto, action2
    }
 }
return

action1:
 {
   msgbox, Good morning! It is now %time%.
 }
return

action2:
 {
   msgbox, Good morning! It is now %time%.
 }
return

emptymem:
 {
   dllcall("psapi.dll\EmptyWorkingSet", "UInt", -1) ;tells Windows to minimize memory use for this script.
 }
return
This can be set to perform desired actions at any specified second of the day, and with some tinkering can include specific dates.
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact