Premereinvio Soluzioni Informatiche

Code Pre 2.0

[ Codice Sync Time from Google ]

Local Const $sFilePath = @ScriptDir &"\AAA-Pre DataGood.log"
FileWrite (@ScriptDir &"\AAA-Pre DataGood.log",">>> Start " & @MDAY & "-" & @MON & "-" & @YEAR & " " & @HOUR & ":" & @MIN & @CRLF)
global $loop = 0
_BeepSingolo()
while 1

    Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_APPEND)
    ;If $hFileOpen = -1 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "Errore apertura del file.")
       ; Return False
    ;EndIf
_BeepSingolo()
		ToolTip("Aggiornamento & sincronizzazione ora... by Premereinvio",@DesktopWidth/2,-1)
$site = "www.google.com"
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "http://" & $site & "/", False)
$oHTTP.Send()
$date = $oHTTP.GetResponseHeader("Date")


Global $tzo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation","ActiveTimeBias")
msgbox(1,"aaa",$tzo)
;Exit
Global $y = StringMid($date,13,4) ; The current year
Global $m = StringMid($date,9,3) ; The current month
Global $d = StringMid($date,6,2) ; The current day of month
Global $h = StringMid($date,18,2) ; The current hour
;$h= $h +2
Global $n = StringMid($date,21,2) ; The current minute
Global $s = StringMid($date,24,2) ; The current second
IF $M = "JAN" THEN $M = 1 ; 31 days in month
IF $M = "FEB" THEN $M = 2 ; 28/29 days in month
IF $M = "MAR" THEN $M = 3 ; 31 days in month
IF $M = "APR" THEN $M = 4 ; 30 days in month
IF $M = "MAY" THEN $M = 5 ; 31 days in month
IF $M = "JUN" THEN $M = 6 ; 30 days in month
IF $M = "JUL" THEN $M = 7 ; 31 days in month
IF $M = "AUG" THEN $M = 8 ; 31 days in month
IF $M = "SEP" THEN $M = 9 ; 30 days in month
IF $M = "OCT" THEN $M = 10 ; 31 days in month
IF $M = "NOV" THEN $M = 11 ; 30 days in month
IF $M = "DEC" THEN $M = 12 ; 31 days in month
Global $epm = _EndOfMonth($M-1) ; The last day of the previous month (28-31)
Global $ecm = _EndOfMonth($M) ; The last day of the current month (28-31); Correct value for $tzo from the registry value to a +/- number of hours
IF $tzo < 1500 Then
$tzo /= -60
Else
$tzo = (4294967296 - $tzo)/60
EndIf

$h += $tzo
; Set the local hour based on offset from UTC
Select ; If the hour changes day forward/backward, correct appropriate values.
Case $h >= 24
     $d += 1
     $h -= 24
Case $h < 0
$d -= 1
$h += 24
EndSelect

Switch $d
; If the day changes month forward/backward, correct appropriate values.
Case $ecm+1
$m += 1
$d = 1
Case 0
$m -= 1
$d = $epm
EndSwitch

Switch $m
; If the month changes year forward/backward, correct appropriate values.
Case 0
$m = 12
$d = 31
$y -= 1
Case 13
$m = 1
$d = 1
$y += 1
EndSwitch

_SetDate($d,$m,$y)
_SetTime($h,$n,$s)
$loop = $loop +1
ConsoleWrite("Loop n. " & $loop)
   ; Write some data.
    FileWrite($hFileOpen, "Aggiorno: " & @MDAY & "-" & @MON & "-" & @YEAR & " " & @HOUR & ":" & @MIN & @CRLF)

FileClose($hFileOpen)
		sleep (5000)
		ToolTip("",-1,-1)

		sleep(59000 * 60)
wend

Func _EndOfMonth($vMON)
local $end
Switch $vMON
Case 0, 1, 3, 5, 7, 8, 10, 12, 13
$end = 31
Case 4, 6, 9, 11
$end = 30
Case 2
If IsInt(@YEAR/4) Then
$end = 29
Else
$end = 28
EndIf
Case Else
SetError(-1)
Return(0)
EndSwitch
Return($end)
EndFunc

Func _Beep()
    Beep(4000, 200)
    Beep(4000, 200)
    Beep(4000, 200)
EndFunc
Func _BeepSingolo()
    Beep(4000, 200)
EndFunc

Func premereinvio1()
	_BrowseURL("http://www.premereinvio.eu")
endfunc

Func _BrowseURL($url="")
   $xyz = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
$text = StringReplace($xyz, "-url", "")
$xyz = $text
$text = StringReplace($xyz, "%1", "")
$xyz = $text
$text = StringReplace($xyz, Chr(34), "")
$xyz = $text
;MsgBox(4096, "WEB Browser", $xyz & " " & $url)
   Run($xyz & " " & $url)
EndFunc