kn007 发表于 2010-1-22 09:00:22

能否调用如图1的系统时钟,或者有无其他函数是个时钟

如果能有函数是个时钟,那么能否调整它的指针


我想显示个时钟,但这个时钟的时间不是电脑的,而是网络获取得到的!?不知明白我的意思

superflq 发表于 2010-1-22 09:02:10

顶一个,`1`获取一个网络地址上的时间,然后显示?

jhwl 发表于 2010-1-22 09:15:39

这是一个计时器:获取一个准确的时间后 初始化计时器 开始工作
上次使用上次发的函数方法二可以处理
http://www.autoitx.com/forum.php?mod=viewthread&tid=12344&extra=&highlight=&page=2

范统.贾 发表于 2010-1-22 10:21:35

楼主英文的OS啊?

onezls 发表于 2010-1-22 10:57:44

修改下面的文本框就可以了

Ailytao6 发表于 2010-1-22 11:08:34

进来瞧瞧看……

netegg 发表于 2010-1-22 13:13:42

官网上无意间看见的
#include <GUIConstants.au3>

Dim $aDigChar
_initDigChar($aDigChar)

Dim $aXY
Global $sec = @SEC
Global $MinDegree = 0
Global $HourDegree = 0
Global $AlarmDegree = 0
Global $alarmHour = 0
Global $alarmMin = 0
Global $alarmSec = 0
Global $alarmIsSet = False
Global $alarmIsSounding = False
Global $previousMinDegree = 0
Global $previousHourDegree = 0
Global $previousAlarmDegree = 0
Global $pi = 3.14159265358979
Global $degToRad = $pi / 180
Global $RadToDeg = 1 / $degToRad

#include <Sound.au3>
Global $alarmFile = @WindowsDir & "\media\ringin.wav"
Global $soundHandle = _SoundOpen($alarmFile)

$gui = GUICreate("Test", 702, 702)
GUISetBkColor(0x000000)

GUISetState()

$megavierkant = GUICtrlCreateGraphic(0, 0, 700, 700)
$vierkant = GUICtrlCreateGraphic(150, 150, 400, 400)
$secSquare = GUICtrlCreateGraphic(0, 0, 0, 0)
$timeSquare = GUICtrlCreateGraphic(5, 5, 200, 30)
$alarmSquare = GUICtrlCreateGraphic(560, 5, 200, 30)

_drawInitBorder($megavierkant)

Dim $msg

While 1
    ; main loop, waits until @sec changes and then executes main drawing management function
    While @SEC = $sec
      $msg = GUIGetMsg(1)
      If $msg = -3 Then Exit
      If $msg = $GUI_EVENT_PRIMARYDOWN Then
            $alarmIsSounding = False
            _SoundStop($soundHandle)
            $mX = $msg - 350
            $mY = $msg - 350
            $clickAngle = Int(ATan($mY / $mX) * $RadToDeg) + 90
            If $mX < 0 Then $clickAngle += 180
            $alarmHour = Int($clickAngle / 30)
            $alarmMin = Mod($clickAngle, 30) * 2
            $alarmSec = 0
            $alarmIsSet = True
            _draw()
      EndIf
      If $msg = $GUI_EVENT_SECONDARYDOWN Then
            $alarmIsSounding = False
            _SoundStop($soundHandle)
            GUICtrlDelete($alarmSquare)
            $alarmIsSet = False
            $alarmHour = -1
            _draw(True)
      EndIf
      Sleep(20)
      If $alarmIsSounding Then _soundAlarm()
    WEnd
    _draw()
    Sleep(50)
    $sec = @SEC
    If (@HOUR = $alarmHour Or @HOUR = 12 + $alarmHour) And @MIN = $alarmMin And $alarmIsSet Then
      $alarmIsSounding = True
    EndIf
WEnd
Exit


Func _soundAlarm()
    If _SoundStatus($soundHandle) = "stopped" Then
      _SoundSeek($soundHandle,0,0,0)
      _SoundPlay($soundHandle, 0)
    EndIf
EndFunc   ;==>_soundAlarm


Func _draw($forceDraw = False)
    ; calculates angles for min/sec dials, manages execution of drawing routines
    Local $doDraw = False
    $MinDegree = Int((90 - @MIN * 6) - @SEC * 0.1)
    $HourDegree = Int((90 - @HOUR * 30) - @MIN * .5)
    $AlarmDegree = Int((90 - $alarmHour * 30) - $alarmMin * .5)
    If $MinDegree <> $previousMinDegree Or $AlarmDegree <> $previousAlarmDegree Then
      $doDraw = True
      $previousMinDegree = $MinDegree
      $previousAlarmDegree = $AlarmDegree
    EndIf

    If $doDraw Or $forceDraw Then
      GUICtrlDelete($vierkant)
      $vierkant = GUICtrlCreateGraphic(150, 150, 400, 400)
      _drawHourPie($vierkant)
      _drawMinPie($vierkant)
      If $alarmIsSet Then _drawAlarmPie($vierkant)
      GUICtrlSetGraphic($vierkant, $GUI_GR_REFRESH)
      $doDraw = False
    EndIf
    Sleep(25)
    _drawSec()
    _drawTime()
    If $alarmIsSet Then _drawAlarmTime()
    GUICtrlSetGraphic($secSquare, $GUI_GR_REFRESH)
EndFunc   ;==>_draw

Func _drawTime()
    ; manages execution of write commands for HH MM SS characters
    GUICtrlDelete($timeSquare)
    $timeSquare = GUICtrlCreateGraphic(5, 5, 200, 30)
    _timeWrite(1, Int(@HOUR / 10), "regular", $timeSquare)
    _timeWrite(20, Mod(@HOUR, 10), "regular", $timeSquare)
    _timeWrite(50, Int(@MIN / 10), "regular", $timeSquare)
    _timeWrite(70, Mod(@MIN, 10), "regular", $timeSquare)
    _timeWrite(100, Int(@SEC / 10), "regular", $timeSquare)
    _timeWrite(120, Mod(@SEC, 10), "regular", $timeSquare)
EndFunc   ;==>_drawTime

Func _drawAlarmTime()
    ; manages execution of write commands for HH MM SS characters for the alarm time
    GUICtrlDelete($alarmSquare)
    $alarmSquare = GUICtrlCreateGraphic(480, 5, 220, 30)
    _timeWrite(1, 10, "alarm", $alarmSquare)
    _timeWrite(20, 11, "alarm", $alarmSquare)
    _timeWrite(50, 12, "alarm", $alarmSquare)
    _timeWrite(80, Int($alarmHour / 10), "alarm", $alarmSquare)
    _timeWrite(100, Mod($alarmHour, 10), "alarm", $alarmSquare)
    _timeWrite(130, Int($alarmMin / 10), "alarm", $alarmSquare)
    _timeWrite(150, Mod($alarmMin, 10), "alarm", $alarmSquare)
    _timeWrite(180, Int($alarmSec / 10), "alarm", $alarmSquare)
    _timeWrite(200, Mod($alarmSec, 10), "alarm", $alarmSquare)
EndFunc   ;==>_drawAlarmTime

Func _timeWrite($pos, $num, $type, $graph) ; $type is "regular" or "alarm"
    ; manages coloring and writing of LEDs for time writing
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 1, 1), $type);0
    _line($graph, $pos + 5, 2, $pos + 3, 10)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 2, 1), $type);1
    _line($graph, $pos + 2, 14, $pos + 0, 22)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 3, 1), $type);2
    _line($graph, $pos + 5 + 2, 0, $pos + 5 + 8, 0)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 4, 1), $type);3
    _line($graph, $pos + 2 + 2, 12, $pos + 2 + 8, 12)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 5, 1), $type);4
    _line($graph, $pos + 2, 24, $pos + 8, 24)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 6, 1), $type);5
    _line($graph, $pos + 5 + 10, 2, $pos + 3 + 10, 10)
   
    _setColorAndPenForWrite(StringMid($aDigChar[$num], 7, 1), $type);6
    _line($graph, $pos + 2 + 10, 14, $pos + 10, 22)
EndFunc   ;==>_timeWrite

Func _line($graph, $x1, $y1, $x2, $y2)
    ; draws line for time writing
    GUICtrlSetGraphic($graph, $GUI_GR_MOVE, $x1 + 2, $y1 + 2)
    GUICtrlSetGraphic($graph, $GUI_GR_LINE, $x2 + 2, $y2 + 2)
EndFunc   ;==>_line

Func _setColorAndPenForWrite($char, $type)
    ; sets color and pen for next line in time writing, based on '0' or '1' in the DigChar array
    If $char = "1"Then
      If $type = "alarm"Then
            GUICtrlSetGraphic($alarmSquare, $GUI_GR_PENSIZE, 2)
            GUICtrlSetGraphic($alarmSquare, $GUI_GR_COLOR, 0xCCCCCC, 0xCCCCCC)
      Else
            GUICtrlSetGraphic($timeSquare, $GUI_GR_PENSIZE, 2)
            GUICtrlSetGraphic($timeSquare, $GUI_GR_COLOR, 0xEE0000, 0xEE0000)
      EndIf
    Else
      If $type = "alarm"Then
            GUICtrlSetGraphic($alarmSquare, $GUI_GR_PENSIZE, 2)
            GUICtrlSetGraphic($alarmSquare, $GUI_GR_COLOR, 0x444444, 0x444444)
      Else
            GUICtrlSetGraphic($timeSquare, $GUI_GR_PENSIZE, 2)
            GUICtrlSetGraphic($timeSquare, $GUI_GR_COLOR, 0x660000, 0x660000)
      EndIf
    EndIf
EndFunc   ;==>_setColorAndPenForWrite

Func _drawSec()
    ; draws circle seconds indicator
    $aXY = _getXY(@SEC, 240)
    GUICtrlDelete($secSquare)
    $secSquare = GUICtrlCreateGraphic(350 + $aXY - 8, 350 + $aXY - 8, 16, 16)
    GUICtrlSetGraphic($secSquare, $GUI_GR_COLOR, 0x0000FF, 0x0000FF)
    GUICtrlSetGraphic($secSquare, $GUI_GR_ELLIPSE, 0, 0, 16, 16)
EndFunc   ;==>_drawSec

Func _drawAlarmPie($graph)
    ; draws alarm dial
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0xDDDDDD, 0xDDDDDD)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 228, $AlarmDegree, 0)
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0xBB9999, 0x000000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 120, $AlarmDegree - 1, 2)
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0x996666, 0x000000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 70, $AlarmDegree - 2, 4)
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0x773333, 0x000000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 20, $AlarmDegree - 4, 8)
    Return True
EndFunc   ;==>_drawAlarmPie

Func _drawMinPie($graph)
    ; draws minute dial
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0xBBBB00, 0xBBBB00)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 200, $MinDegree - 2, 4)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 220, $MinDegree, 0)
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0x000000, 0x000000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 150, $MinDegree - 1, 2)
    Return True
EndFunc   ;==>_drawMinPie

Func _drawHourPie($graph)
    ; draws hour dial
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0xAA0000, 0xAA0000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 140, $HourDegree - 4, 8)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 160, $HourDegree, 0)
    GUICtrlSetGraphic($graph, $GUI_GR_COLOR, 0x000000, 0x000000)
    GUICtrlSetGraphic($graph, $GUI_GR_PIE, 200, 200, 120, $HourDegree - 1, 2)
    Return True
EndFunc   ;==>_drawHourPie

Func _getXY($sec, $hypo)
    ; returns array with X,Y coordinates for the seconds points for $sec seconds, with $hypo(tenuse) distance from center
    Dim $result
    Local $pi = 3.14159265358979
    Local $degToRad = $pi / 180
    Local $degrees = $sec * 6 - 90
    Local $x = Cos($degrees * $degToRad) * $hypo
    Local $y = Sin($degrees * $degToRad) * $hypo
    $result = $x
    $result = $y
    Return $result
EndFunc   ;==>_getXY

Func _drawInitBorder($megavierkant)
    ; draws initial border 'circle'
    For $count = 1 To 60
      If $count / 5 = Int($count / 5) Then
            Dim $a1 = _getXY($count, 260)
            Dim $a2 = _getXY($count, 280)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_PENSIZE, 4)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_COLOR, 0x00CC00, 0x00CC00)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_MOVE, 350 + $a1, 350 + $a1)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_LINE, 350 + $a2, 350 + $a2)
      Else
            Dim $a1 = _getXY($count, 270)
            Dim $a2 = _getXY($count, 280)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_PENSIZE, 3)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_COLOR, 0x008800, 0x008800)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_MOVE, 350 + $a1, 350 + $a1)
            GUICtrlSetGraphic($megavierkant, $GUI_GR_LINE, 350 + $a2, 350 + $a2)
      EndIf
    Next
EndFunc   ;==>_drawInitBorder

Func _initDigChar(ByRef $aDigChar)
    ; define leds for digital numbers: 1 or 0 for leds on/off in 7-led digital clock characters
    $aDigChar = "1110111"
    $aDigChar = "0000011"
    $aDigChar = "0111110"
    $aDigChar = "0011111"
    $aDigChar = "1001011"
    $aDigChar = "1011101"
    $aDigChar = "1111101"
    $aDigChar = "0010011"
    $aDigChar = "1111111"
    $aDigChar = "1011111"
    $aDigChar = "1111011" ; A
    $aDigChar = "1100100" ; L
    $aDigChar = "0001000" ; -
EndFunc   ;==>_initDigChar

kn007 发表于 2010-1-22 17:14:40

官网上无意间看见的
#include

Dim $aDigChar
_initDigChar($aDigChar)

Dim $aXY
Global $ ...
netegg 发表于 2010-1-22 13:13 http://www.autoitx.com/images/common/back.gif

XD知我心啊!!!

rikthhpgf2005 发表于 2010-1-29 19:03:35

还是可以的,改下可以用

qixinwb 发表于 2010-1-29 20:18:15

佩服至极!:face (29):

zmj2008 发表于 2010-3-16 09:05:39

又好看又使用佩服怎么不发到源码区 让更多的人用呢
页: [1]
查看完整版本: 能否调用如图1的系统时钟,或者有无其他函数是个时钟