Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $HTTP = ObjCreate("winhttp.winhttprequest.5.1") ; Creates the HTTP requests variable. I name it relevent to what the variable does
- $Error = ObjEvent("AutoIt.Error", "_Error") ; Creates an error handler. If there's an error, the program won't crash. Isn't needed, but if your program is unstable, it keeps it going.
- _ProcessReduceMemory(@AutoItPID) ; Isn't needed, but reduces memory so it hogs less resources
- _ProcessReduceMemory("AutoIt3Wrapper.exe") ; Isn't needed, reduces memory so it hogs less resources
- Get() ; You don't /need/ to call the function, but I like my scripts to be tidy
- Func Get() ; Now here's the function
- $HTTP.Open("GET", "http://whatismyipaddress.com/", False) ; Opens a GET request to the IP address site, basically it's viewing the page source
- $HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5") ; Sets the User Agent
- $HTTP.Send() ; Not sure what this does, really. I guess it just tells it to send with the desired credentials
- $HTTP.ResponseText ; The response of what it just sent
- $IP = _StrBetween($HTTP.ResponseText, '<h2 style="margin:0;">IP Information: <span class="ip blue">', '<!-- contact us before using a script to get your IP address --></span></h2>') ; This tells that you want your IP. If you look in the page source, it looks something like this. In this line of code we want to know the IP, or whatever is in between the string, so we add a comma, basically saying "Hey, I want whatever is between ___ and ___"
- ConsoleWrite($IP & @CRLF) ; Run this from sciTE
- EndFunc
- Func _StrBetween($sArg_01, $sArg_02, $sArg_03) ; I didn't make this, but this is the _StrBetween function. It basically gets the string from a desired page source, but you have to specify to tell it where, and what you want. Good for getting changing values from a page source, or just getting something from the source in general
- Local $sStr_X, $sStr_Y
- $sStr_X = StringInStr($sArg_01, $sArg_02) + StringLen($sArg_02)
- $sStr_Y = StringInStr(StringTrimLeft($sArg_01, $sStr_X), $sArg_03)
- Return StringMid($sArg_01, $sStr_X, $sStr_Y)
- EndFunc ;==>_StrBetween
- Func _ProcessReduceMemory($iPID) ; Once again, not made by me, but it makes it so the script takes up less memory. :3
- Local $iProcExists = ProcessExists($iPID)
- If Not $iProcExists Then Return SetError(1, 0, 0)
- If IsString($iPID) Then $iPID = $iProcExists
- Local $hOpenProc, $aResult
- $hOpenProc = DllCall("Kernel32.dll", "int", "OpenProcess", "int", 0x1F0FFF, "int", False, "int", $iPID)
- $aResult = DllCall("Kernel32.dll", "int", "SetProcessWorkingSetSize", "hwnd", $hOpenProc[0], "int", -1, "int", -1)
- DllCall("Kernel32.dll", "int", "CloseHandle", "int", $hOpenProc[0])
- If Not IsArray($aResult) Or $aResult[0] = 0 Then Return SetError(2, 0, 0)
- Return $aResult[0]
- EndFunc ;==>_ProcessReduceMemory
- Func _Error() ; If there's any error, it'll just say there's an error, rather than crashing. Isn't really needed in this script, but you never know when something might happen.
- ConsoleWrite("Errored" & @CRLF)
- EndFunc ;==>_Error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement