Advertisement
Guest User

Untitled

a guest
Aug 20th, 2010
2,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.06 KB | None | 0 0
  1. $HTTP = ObjCreate("winhttp.winhttprequest.5.1") ; Creates the HTTP requests variable. I name it relevent to what the variable does
  2. $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.
  3.  
  4. _ProcessReduceMemory(@AutoItPID) ; Isn't needed, but reduces memory so it hogs less resources
  5. _ProcessReduceMemory("AutoIt3Wrapper.exe") ; Isn't needed, reduces memory so it hogs less resources
  6.  
  7. Get() ; You don't /need/ to call the function, but I like my scripts to be tidy
  8.  
  9. Func Get() ; Now here's the function
  10.     $HTTP.Open("GET", "http://whatismyipaddress.com/", False) ; Opens a GET request to the IP address site, basically it's viewing the page source
  11.     $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
  12.     $HTTP.Send() ; Not sure what this does, really. I guess it just tells it to send with the desired credentials
  13.     $HTTP.ResponseText ; The response of what it just sent
  14.     $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 ___"
  15.     ConsoleWrite($IP & @CRLF) ; Run this from sciTE
  16. EndFunc
  17.  
  18. 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
  19.     Local $sStr_X, $sStr_Y
  20.     $sStr_X = StringInStr($sArg_01, $sArg_02) + StringLen($sArg_02)
  21.     $sStr_Y = StringInStr(StringTrimLeft($sArg_01, $sStr_X), $sArg_03)
  22.     Return StringMid($sArg_01, $sStr_X, $sStr_Y)
  23. EndFunc   ;==>_StrBetween
  24.  
  25. Func _ProcessReduceMemory($iPID) ; Once again, not made by me, but it makes it so the script takes up less memory. :3
  26.     Local $iProcExists = ProcessExists($iPID)
  27.     If Not $iProcExists Then Return SetError(1, 0, 0)
  28.     If IsString($iPID) Then $iPID = $iProcExists
  29.     Local $hOpenProc, $aResult
  30.     $hOpenProc = DllCall("Kernel32.dll", "int", "OpenProcess", "int", 0x1F0FFF, "int", False, "int", $iPID)
  31.     $aResult = DllCall("Kernel32.dll", "int", "SetProcessWorkingSetSize", "hwnd", $hOpenProc[0], "int", -1, "int", -1)
  32.     DllCall("Kernel32.dll", "int", "CloseHandle", "int", $hOpenProc[0])
  33.     If Not IsArray($aResult) Or $aResult[0] = 0 Then Return SetError(2, 0, 0)
  34.     Return $aResult[0]
  35. EndFunc   ;==>_ProcessReduceMemory
  36.  
  37. 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.
  38.     ConsoleWrite("Errored" & @CRLF)
  39. EndFunc   ;==>_Error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement