 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Highspeedy Guest
|
Posted: Wed Apr 27, 2005 4:22 pm Post subject: How can I get the system time |
|
|
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
|
Posted: Wed Apr 27, 2005 4:27 pm Post subject: |
|
|
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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Wed Apr 27, 2005 4:30 pm Post subject: |
|
|
Also, FormatTime allows you to change A_Now to something more understandable. _________________
 |
|
| Back to top |
|
 |
Highspeedy Guest
|
Posted: Wed Apr 27, 2005 4:36 pm Post subject: Thank You |
|
|
Thanks guys,
that´s really a simple solution
It´s late in the afternoon in Germany and I should shut down the PC...
 |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Wed Apr 27, 2005 8:33 pm Post subject: clock |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Thu Apr 28, 2005 10:16 pm Post subject: |
|
|
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 |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Thu Apr 28, 2005 11:00 pm Post subject: |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Thu Apr 28, 2005 11:24 pm Post subject: |
|
|
| 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 |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Thu Apr 28, 2005 11:58 pm Post subject: |
|
|
Or you could add a "Gui,Show,AutoSize" _________________ Ciao
toralf  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Fri Apr 29, 2005 10:26 am Post subject: |
|
|
| Laszlo (hungarian?) and toralf thank you for your help |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Apr 29, 2005 2:39 pm Post subject: |
|
|
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 |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Fri Apr 29, 2005 6:03 pm Post subject: |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Apr 29, 2005 6:22 pm Post subject: |
|
|
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|