获取网络时间 萌新版

快速简单的获取网络时间·代替本地时间不准的用
MsgBox, % "当前网络时间:" GetTime()

GetTime() {
	local whr, gTime
	whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	whr.Open("GET", "http://quan.suning.com/getSysTime.do", true)
	whr.Send()
	whr.WaitForResponse()
	Time := whr.ResponseText
	Text:=SubStr(Time,-15)
    年:=SubStr(Text,1,4)
    月:=SubStr(Text,5,2)
    日:=SubStr(Text,7,2)
    时:=SubStr(Text,9,2)
    分:=SubStr(Text,11,2)
    秒:=SubStr(Text,13,2)
	return 时 ":" 分 ":" 秒
}

可以用RegExReplace正则代替SubStr(我对正则不熟所以就用笨方法了)

给TA捐赠
共{{data.count}}人
人已捐赠
教程

正则替换时调用函数 By FeiYue

2021-7-22 13:53:43

其他应用案例

小巧的计时器 萌新也可以看懂

2021-7-23 8:57:28

3 条回复 A文章作者 M管理员
  1. AHK中文社区

    main:
    MsgBox, % “当前网络时间:” getTime()
    return
    getTime() {
    local whr, gTime
    whr := ComObjCreate(“WinHttp.WinHttpRequest.5.1”)
    whr.Open(“GET”, “http://quan.suning.com/getSysTime.do”, true)
    whr.Send()
    whr.WaitForResponse()
    gTime := whr.ResponseText
    RegExMatch(gTime, “sysTime1.{3}(\d+)”, rtTime)
    return rtTime1
    }

个人中心
购物车
优惠劵
有新私信 私信列表
搜索