Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/01/2011 in all areas

  1. ProgAndy

    WinHTTP functions

    If you want to ddecompress GZ-encoded responses, use the zlib.au3: #include<WinHttp.au3> #include<zlib.au3> $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.0.3; .NET CLR 2.0.50727; ffco7) Gecko/2008092417 Firefox/3.0.3") $hConnect = _WinHttpConnect($hOpen, "www.rlslog.net") ;~ $hRequest = _WinHttpSimpleRequest($hConnect) $aRequest = _WinHttpSimpleRequest($hConnect, Default,Default,Default,Default,'Accept-Encoding: gzip',1,2) $charset = 0 If StringRegExp($aRequest[0], "(?im)^Content-Type:\h.*?charset\h*=\h*utf-?8") Then $charset = 4 If StringRegExp($aRequest[0], "(?im)^Content-Encoding:\h+gzip") Then $sResponse = BinaryToString(_ZLIB_GZUncompress($aRequest[1]), $charset) Else $sResponse = BinaryToString($aRequest[1], $charset) EndIf ConsoleWrite($sResponse & @LF) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
    1 point
  2. trancexx

    WinHTTP functions

    That's gzip compressed, read the header. You could try forcing uncompressed response: _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: gzip;q=0") or maybe: _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: *;q=0") ... but at the end it's the server making the rules. If it want's it can ignore your wishes.
    1 point
  3. Here's the function that I use (typically in a While... Wend loop, which should suit your requested usage well): Global Const $DESKTOP_SWITCHDESKTOP = 0x100 Func _CheckLocked() $hLockedDLL = DllOpen("user32.dll") $hDesktop = DllCall($hLockedDLL, "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $ret = DllCall($hLockedDLL, "int", "SwitchDesktop", "int", $hDesktop[0]) DllCall($hLockedDLL, "int", "CloseDesktop", "int", $hDesktop[0]) If $ret[0] = 0 Then $iLocked = 1 ElseIf $ret[0] = 1 Then $iLocked = 0 EndIf DllClose($hLockedDLL) If $iLocked Then Return 1 Else Return 0 EndIf EndFunc Edit: Added the Global Constant needed by the function
    1 point
×
×
  • Create New...