Jump to content

Atomic Clock


scintilla4evr
 Share

Recommended Posts

I want to introduce you simple atomic clock.

It retreives data from http://www.atomic-clock.org.uk/atomic-clock.php.

Code:

#cs
    Atomic Clock 1.0
    By scintilla4evr
#ce

#include <GUIConstants.au3>
#include <IE.au3>

Global $sURL = "http://www.atomic-clock.org.uk/atomic-clock.php"

$hGUI = GUICreate("Atomic Clock", 300, 100)
$cidTime = GUICtrlCreateLabel("", 0, 0, 300, 100)
GUICtrlSetFont(-1, 58)
GUISetState()

$oIE = _IECreate($sURL, 0, 0)
AdlibRegister("QuickClose", 1)
AdlibRegister("Timer", 1)

While 1
    Switch GUIGetMsg()
        Case -3
            ExitLoop
    EndSwitch
WEnd

AdlibUnRegister("QuickClose")
AdlibUnRegister("Timer")
_IEQuit($oIE)

Func QuickClose()
    If GUIGetMsg() = -3 Then
        AdlibUnRegister("QuickClose")
        AdlibUnRegister("Timer")
        _IEQuit($oIE)
        Exit
    EndIf
EndFunc

Func Timer()
    $oTimeObj = _IEGetObjById($oIE, "anzeige_zeit")
    $sTime = _IEPropertyGet($oTimeObj, "innertext")
    GUICtrlSetData($cidTime, $sTime)
    $oTimeObj = 0
EndFunc

Details:

Performance: POOR

Size: 870 B

If someone asks, why you need this, say:

BECAUSE NO ONE HAS.

Link to comment
Share on other sites

scintilla4evr;

changes below are (opinion) improvements to performance.

#cs
    Atomic Clock 1.0
    By scintilla4evr
#ce
#include <GUIConstantSex.au3>
#include <GUIConstants.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Global $sURL = "http://www.atomic-clock.org.uk/atomic-clock.php"

$hGUI = GUICreate("Atomic Clock", 300, 100, Default, Default, $GUI_SS_DEFAULT_GUI, $WS_EX_COMPOSITED);COMPOSITED is what I was after
$cidTime = GUICtrlCreateLabel("", 0, 0, 300, 100)
GUICtrlSetFont(-1, 58)
GUISetState()

$oIE = _IECreate($sURL, 0, 0)
;AdlibRegister("QuickClose", 1)
AdlibRegister("Timer", 100);**

DllCall("psapi.dll", "bool", "EmptyWorkingSet", "handle", -1)

While 1
    Switch GUIGetMsg()
        Case -3
            ExitLoop
    EndSwitch
WEnd

;AdlibUnRegister("QuickClose")
AdlibUnRegister("Timer")
_IEQuit($oIE)

;Func QuickClose()
    ;If GUIGetMsg() = -3 Then
        ;AdlibUnRegister("QuickClose")
        ;AdlibUnRegister("Timer")
       ; _IEQuit($oIE)
       ; Exit
    ;EndIf
;EndFunc

Func Timer()
    $oTimeObj = _IEGetObjById($oIE, "anzeige_zeit")
    $sTime = _IEPropertyGet($oTimeObj, "innertext")
    GUICtrlSetData($cidTime, $sTime)
    $oTimeObj = 0
EndFunc
Link to comment
Share on other sites

scintilla4evr,

Looking at the web page the tab for browser updates time as well. So why not update the Window Title with the time as well.

Also cleaned up the code a little. Didn't show the GUI until after webpage is created that way the GUI isn't empty while waiting on information. Also since it is a simple code removed includes and just replaced with value.

#cs
    Atomic Clock 1.0
    By scintilla4evr
#ce
#include <IE.au3>
Opt("WinTitleMatchMode", 2)
GUICreate("Atomic Clock", 300, 100, -1, -1, -1, 0x02000000)
$cidTime = GUICtrlCreateLabel("", 0, 0, 300, 100)
GUICtrlSetFont(-1, 58)
$oIE = _IECreate("http://www.atomic-clock.org.uk/atomic-clock.php", 0, 0)
AdlibRegister("Timer", 100)
GUISetState()

While 1
    If GUIGetMsg() = -3 Then ExitLoop
WEnd

AdlibUnRegister("Timer")
_IEQuit($oIE)

Func Timer()
    $oTimeObj = _IEGetObjById($oIE, "anzeige_zeit")
    $sTime = _IEPropertyGet($oTimeObj, "innertext")
    GUICtrlSetData($cidTime, $sTime)
    WinSetTitle("Atomic Clock", "", $sTime & " : Atomic Clock")
EndFunc
Edited by Rogue5099
Link to comment
Share on other sites

  • Moderators

Rogue5099,

 

Also since it is a simple code removed includes and just replaced with value

Very bad coding practice and not to be encouraged. Use the variable names as then you will not be looking at the code in a few months (or even days if you reach a certain age) and thinking: "WTF does that mean?". ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Very bad coding practice and not to be encouraged. Use the variable names as then you will not be looking at the code in a few months (or even days if you reach a certain age) and thinking: "WTF does that mean?". ;)

Undertandable, so here  :thumbsup: :

 

#include <IE.au3>
Global Const $WS_EX_COMPOSITED = 0x02000000
Global Const $GUI_EVENT_CLOSE = -3
Opt("WinTitleMatchMode", 2)
GUICreate("Atomic Clock", 300, 100, -1, -1, -1, $WS_EX_COMPOSITED)
$cidTime = GUICtrlCreateLabel("", 0, 0, 300, 100)
GUICtrlSetFont(-1, 58)
$oIE = _IECreate("http://www.atomic-clock.org.uk/atomic-clock.php", 0, 0)
AdlibRegister("Timer", 100)
GUISetState()

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

AdlibUnRegister("Timer")
_IEQuit($oIE)

Func Timer()
    $oTimeObj = _IEGetObjById($oIE, "anzeige_zeit")
    $sTime = _IEPropertyGet($oTimeObj, "innertext")
    GUICtrlSetData($cidTime, $sTime)
    WinSetTitle("Atomic Clock", "", $sTime & " : Atomic Clock")
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...