MSLx Fanboy Posted June 1, 2005 Share Posted June 1, 2005 I wrote the script for personal use, since my cable company likes to use Dynamic IP addressing on its network...so I can update my dns entries while out of the house, or just use the IP itself to get access... expandcollapse popup#include <Inet.au3> Dim $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler") Global $youremail = "Some Person <someperson@organization.com>" Global $smtpserver = "mail.organization.com" Global $smtpuser = "mailusername" Global $smtppass = "mailpassword" #Region Do Not Change HotKeySet("{ESC}", "QuitIPChecking") While 1 $PublicIP = _GetIP() $RegistryIP = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion", "PublicIP") Select Case $RegistryIP = "" RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion", "PublicIP", "REG_SZ", $PublicIP) SendEmail() Case $RegistryIP <> $PublicIP SendEmail() EndSelect WEnd Func SendEmail() $objMessage = ObjCreate ("CDO.Message") With $objMessage .Subject = @ComputerName & "'s Public IP Address Has Changed" .Sender = $youremail .From = $youremail .To = $youremail .TextBody = @ComputerName & "'s IP Address has changed. New IP Address: " & @CRLF & $PublicIP EndWith With $objMessage.Configuration.Fields .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $smtpuser .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $smtppass .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 .Update EndWith $objMessage.Send EndFunc ;==>SendEmail Func QuitIPChecking() Exit EndFunc Func ErrorHandler() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1); to check for after this function returns EndFunc ;==>ErrorHandler #EndRegion Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
ragemxf Posted February 2, 2007 Share Posted February 2, 2007 I wrote the script for personal use, since my cable company likes to use Dynamic IP addressing on its network...so I can update my dns entries while out of the house, or just use the IP itself to get access... expandcollapse popup#include <Inet.au3> Dim $oMyError = ObjEvent ("AutoIt.Error", "ErrorHandler") Global $youremail = "Some Person <someperson@organization.com>" Global $smtpserver = "mail.organization.com" Global $smtpuser = "mailusername" Global $smtppass = "mailpassword" #Region Do Not Change HotKeySet("{ESC}", "QuitIPChecking") While 1 $PublicIP = _GetIP() $RegistryIP = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion", "PublicIP") Select Case $RegistryIP = "" RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion", "PublicIP", "REG_SZ", $PublicIP) SendEmail() Case $RegistryIP <> $PublicIP SendEmail() EndSelect WEnd Func SendEmail() $objMessage = ObjCreate ("CDO.Message") With $objMessage .Subject = @ComputerName & "'s Public IP Address Has Changed" .Sender = $youremail .From = $youremail .To = $youremail .TextBody = @ComputerName & "'s IP Address has changed. New IP Address: " & @CRLF & $PublicIP EndWith With $objMessage.Configuration.Fields .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $smtpuser .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $smtppass .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 .Update EndWith $objMessage.Send EndFunc ;==>SendEmail Func QuitIPChecking() Exit EndFunc Func ErrorHandler() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1); to check for after this function returns EndFunc ;==>ErrorHandler #EndRegion GETTING UNKNOWN FUNCTION NAMES ERRORS ON LINE 2 and 25 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now