Skip to content

Instantly share code, notes, and snippets.

@tamr
Last active April 4, 2023 16:42
Show Gist options
  • Save tamr/ea00a7ace5a8032b6e259c2827ee04b1 to your computer and use it in GitHub Desktop.
Save tamr/ea00a7ace5a8032b6e259c2827ee04b1 to your computer and use it in GitHub Desktop.
On Error Resume Next
Const getIP = "http://checkip.amazonaws.com/"
Set ReExpObj = New RegExp
With ReExpObj
.Pattern = "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
.IgnoreCase = True
.Global = True
End With
Set http = createobject("microsoft.xmlhttp")
http.open "GET", getIP, False
http.send
Set oMatches = ReExpObj.Execute(http.responsetext)
If oMatches.Count > 0 Then
Set oMatch = oMatches(0)
http.open "POST", "https://push.re/message?token=appToken", False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.send "priority=1&title=Windows login&message=Login from IP: " + oMatch.Value
End if
On Error Goto 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment