AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I get the system time

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Highspeedy
Guest





PostPosted: Wed Apr 27, 2005 4:22 pm    Post subject: How can I get the system time Reply with quote

Is there a command available for getting and copying the (local) system time into a variable ?
Sorry, I can´t find any command at the moment and I don´t have any other idea how to get the system time.

Thanks
Back to top
TeknoMusicMan



Joined: 14 Apr 2005
Posts: 188
Location: Wisconsin, USA

PostPosted: Wed Apr 27, 2005 4:27 pm    Post subject: Reply with quote

check out Variables and Expressions.

specifically:
A_Now
A_Hour
A_Min
_________________

"Make it idiot-proof, and someone will make a better idiot."
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Wed Apr 27, 2005 4:30 pm    Post subject: Reply with quote

Also, FormatTime allows you to change A_Now to something more understandable.
_________________

Back to top
View user's profile Send private message Visit poster's website
Highspeedy
Guest





PostPosted: Wed Apr 27, 2005 4:36 pm    Post subject: Thank You Reply with quote

Thanks guys,

that´s really a simple solution Rolling Eyes

It´s late in the afternoon in Germany and I should shut down the PC...

Shocked
Back to top
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Wed Apr 27, 2005 8:33 pm    Post subject: clock Reply with quote

example for clock (close with escape)
Code:

#NoTrayIcon
Gui, +AlwaysOnTop  +Disabled -SysMenu
Gui, -Border
Gui, Font, S8 , Verdana
Gui, Color, 000000
Gui, Show, x200 y0 w220 h33, CLOCK
{
Gui, Font, S8 cwhite, Verdana
Gui, Add, Text, x10 Y10 vD , %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min%:%a_sec%
SetTimer, RefreshD, 1000
RefreshD:
GuiControl, , D, %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min%:%a_sec%
return
}
Return
ESC::ExitApp


Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Thu Apr 28, 2005 10:16 pm    Post subject: Reply with quote

Thanks, Garry, for the clock script! It works nicely. One can make minor improvements, though: remove duplicates, change the order of commands, leave the width of the clock window open (so it fits to the changing length of the name of the day) and use GuiEscape to quit (i.e. first select the clock then press Esc), so the function of the Esc key in other windows are not affected. The font size, window position, height should be adjusted to the actual screen resolution. The given values are nice on my 1600x1200 pixel monitor, with large system fonts.
Code:
#NoTrayIcon
SetTimer RefreshD, 1000

Gui +AlwaysOnTop -SysMenu -Border
Gui Color, 0
Gui Font, S10 cwhite, Verdana
Gui Add, Text, x10 Y2 vD, %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
Gui Show, x200 y0 h24, CLOCK

RefreshD:
GuiControl,,D, %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
return

GuiEscape:
ExitApp
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Thu Apr 28, 2005 11:00 pm    Post subject: Reply with quote

Ok, I know I'm picky, but I can't help it. So pleas don't bash me. :)

Just for clearness: You could add a "return" in the line before "RefreshD:". It doesn't effect the outcome of the script, but the structure is better (there would be no overlap between routines).

I like the GuiEscape function. I will apply it for one of my scripts without border as well, thanks for posting.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Thu Apr 28, 2005 11:24 pm    Post subject: Reply with quote

It was intentional to "flow" in the RefreshD. I see your point, toralf, at least a comment should be there about it. But there is a real issue with the script: you should not run it over midnight, because the window size is set at the call, and if the day changes its name might not fit in. If someone finds it disturbing, he has to close and show the window again.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Thu Apr 28, 2005 11:58 pm    Post subject: Reply with quote

Or you could add a "Gui,Show,AutoSize"
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Fri Apr 29, 2005 10:26 am    Post subject: Reply with quote

Laszlo (hungarian?) and toralf thank you for your help
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Fri Apr 29, 2005 2:39 pm    Post subject: Reply with quote

Garry, I don't think you needed help. Your script works. I just wanted to arrange your clock code such that I understand. Pure selfishness… (Laszlo the Great of Hungary)

Toralf, I tried AutoSize, and it did not work for me (Win2K). When the name of the day got longer, the time was cut off, only the date was visible. Also, doing this AutoSize at every update of the clock seems to consume a lot of processing time: the applications became irresponsive, the mouse moved jerky, etc. Maybe a future AHK release will address the many graphic performance issues we have encountered. The best clock version I found so far is below. It destroys and re-draws the clock window when the day changes. The first time the script is executed the DrawD label is just in the auto execute part. When the day changes, the RefreshD routine jumps there and terminates with the Return after DrawD. This saves a couple of lines of code, but violates the Kill-the-GoTo policy. In an eighteen-liner this trick might be OK, but don't try it at home (for complex scripts).
Code:
#NoTrayIcon
Day = %A_DD%
SetTimer RefreshD, 1000

DrawD:
Gui +AlwaysOnTop -SysMenu -Border
Gui Color, 0
Gui Font, S10 cwhite, Verdana
Gui Add, Text, x10 Y2 vD, %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
Gui Show, x200 y0 h24, Clock
return

RefreshD:
GuiControl,,D, %A_DDDD%  %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
IfEqual Day,%A_DD%, Return
Day = %A_DD%
Gui Destroy
GoTo DrawD

GuiEscape:
ExitApp
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Fri Apr 29, 2005 6:03 pm    Post subject: Reply with quote

Lászlo, ne dolgozzál éjfélig
Laszlo,don't work till midnight
here a script transparent never hidden
good idea when date changes, here define date size lenght
Code:
;dateonscreen.ahk  2005-04-29 garry
;display the date and time transparent never hidden
#singleinstance force
;screenposition=
X1=500
Y1=3
;COLOR and SIZE=
;R=CFF0000 S7   ;red
;R=C000000 S7   ;black
R=CFFFFFF S7   ;white

Gui,+AlwaysOnTop +ToolWindow -SysMenu -Caption
Gui,Color,CCCCCC
Gui,Font,%R%, verdana
{
C1=%A_DDDD% %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min%:%a_sec%                 END
stringmid,C,C1,1,40
Gui,Add,Text,vD,%C%
Gui,Show,x%X1% y%Y1%,uptime
WinSet,TransColor,CCCCCC 255,uptime
SetTimer,RefreshD,1000
RefreshD:
C1=%A_DDDD% %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min%:%a_sec%                 END
stringmid,C,C1,1,40
GuiControl,,D,%C%
return
}
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Fri Apr 29, 2005 6:22 pm    Post subject: Reply with quote

Quote:
Lászlo, ne dolgozzál éjfélig
Még csak délután van Pittsburgh-ben (It is only afternoon, here in Pittsburgh.) Your new script works, too, except if the window title happens to be also white, when I cannot see the date. I liked the white on black version better.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group