Plain text
复制到剪贴板
Open code in new window
EnlighterJS 3 Syntax Highlighter
#NoEnv
SetBatchLines -1
SetWorkingDir %A_ScriptDir%
; 地址一
MsgBox % 请求返回("http://icanhazip.com/")
; 地址二【GPT写的】
url := "http://httpbin.org/ip" ; 使用httpbin.org提供的服务获取外网IP
httpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
httpRequest.Open("GET", url)
httpRequest.Send()
httpRequest.WaitForResponse()
responseText := httpRequest.ResponseText
ipStartPos := InStr(responseText, """origin"": """) + 10
ipEndPos := InStr(responseText, """", false, ipStartPos + 1)
ipAddress := SubStr(responseText, ipStartPos, ipEndPos - ipStartPos)
MsgBox, % "您的外部IP地址是: " ipAddress
请求返回(URL, Request1="") {
Local
Try {
Httpwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
if Request1=
Httpwhr.Open("GET", URL, true), Httpwhr.Send()
else
Httpwhr.Open("POST", URL), Httpwhr.Send(Request1)
Httpwhr.WaitForResponse()
return Httpwhr.ResponseText
}
}
#NoEnv SetBatchLines -1 SetWorkingDir %A_ScriptDir% ; 地址一 MsgBox % 请求返回("http://icanhazip.com/") ; 地址二【GPT写的】 url := "http://httpbin.org/ip" ; 使用httpbin.org提供的服务获取外网IP httpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") httpRequest.Open("GET", url) httpRequest.Send() httpRequest.WaitForResponse() responseText := httpRequest.ResponseText ipStartPos := InStr(responseText, """origin"": """) + 10 ipEndPos := InStr(responseText, """", false, ipStartPos + 1) ipAddress := SubStr(responseText, ipStartPos, ipEndPos - ipStartPos) MsgBox, % "您的外部IP地址是: " ipAddress 请求返回(URL, Request1="") { Local Try { Httpwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1") if Request1= Httpwhr.Open("GET", URL, true), Httpwhr.Send() else Httpwhr.Open("POST", URL), Httpwhr.Send(Request1) Httpwhr.WaitForResponse() return Httpwhr.ResponseText } }
#NoEnv
SetBatchLines -1
SetWorkingDir %A_ScriptDir%

; 地址一
MsgBox % 请求返回("http://icanhazip.com/")

; 地址二【GPT写的】
url := "http://httpbin.org/ip"  ; 使用httpbin.org提供的服务获取外网IP
httpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
httpRequest.Open("GET", url)
httpRequest.Send()
httpRequest.WaitForResponse()

responseText := httpRequest.ResponseText
ipStartPos := InStr(responseText, """origin"": """) + 10
ipEndPos := InStr(responseText, """", false, ipStartPos + 1)
ipAddress := SubStr(responseText, ipStartPos, ipEndPos - ipStartPos)

MsgBox, % "您的外部IP地址是: " ipAddress



请求返回(URL, Request1="") {
  Local
  Try {
    Httpwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    if Request1=
      Httpwhr.Open("GET", URL, true), Httpwhr.Send()
     else
      Httpwhr.Open("POST", URL), Httpwhr.Send(Request1)
    Httpwhr.WaitForResponse()
    return Httpwhr.ResponseText
  }
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。