blog

当前位置:首页>文章中心>blog
今天写了个au3同步系统时间小程序
blog 2016-06-19 1 阅读

今天写了个au3同步系统时间小程序

小泥巴 小泥吧科技 2016-06-19
经常手工设置系统时间麻烦,今天翻翻AU3写鸟个小程序 。方便以后使用。 下载:syncTime          syncTime_x64 代码:
#Region ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#AccAu3Wrapper_Icon=imgic_sync_time.ico
#AccAu3Wrapper_Outfile=syncTime.exe
#AccAu3Wrapper_Outfile_x64=syncTime_x64.exe
#AccAu3Wrapper_UseUpx=y
#AccAu3Wrapper_Compile_Both=y
#AccAu3Wrapper_Res_Language=2052
#AccAu3Wrapper_Res_requestedExecutionLevel=None
#AccAu3Wrapper_Add_Constants=y
#EndRegion ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#include
#include 
#include 
#include 
#include 

$url = "http://tool.xiaoniba.com/au3/setSystemTime.php"
$data = "act=getTime";
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rs = postData($url,$data)
If Not $rs Then
MsgBox($MB_ICONWARNING,"时间同步-powered by 小泥吧科技","貌似连不上服务器 -_-",5)
Exit
EndIf
;MsgBox(0,"",$rs)
$rs = _StringExplode($rs,@CRLF)
$Ymd = _StringExplode($rs[0],"/",3)
$His = _StringExplode($rs[1],":",3)
;_ArrayDisplay($Ymd)
;_ArrayDisplay($His)
setSystemTime($Ymd[0],$Ymd[1],$Ymd[2],$His[0],$His[1],$His[2])
;MsgBox(0,"",$year)
MsgBox($MB_ICONINFORMATION,"时间同步-powered by 小泥吧科技","从 xiaoniba.com 同步时间成功!",10)

;;;;;;;************************************************************************
Func setSystemTime($year,$mon,$mday,$hour,$min,$sec)
	; Set new system time
    $tNew = _Date_Time_EncodeSystemTime($mon,$mday,$year,$hour,$min,$sec)
    If Not _Date_Time_SetLocalTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
EndFunc

;;定义post请求函数
Func postData($url, $data)
	$oHTTP = ObjCreate("Microsoft.xmlhttp")
	$oHTTP.Open("POST", $url, False)
	$oHTTP.setRequestHeader("Cache-Control", "no-cache")
	$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	$oHTTP.Send($data);post关键数据
	$oText = $oHTTP.responsetext
	Return $oText

EndFunc   ;==>postData

Func MyErrFunc()
	;可以什么都不做,目的为了防止忘了超时导致程序崩溃。
EndFunc   ;==>MyErrFunc
 
相关标签:

发表评论:

评论记录:

未查询到任何数据!
QQ咨询
回电话
回拨通话

我们稍后回拨您的电话

座机请加区号

微信联系
微信扫一扫
微信二维码

扫码加微信