Webscan über Netzwerkdrucker

  • Guten Abend

    Ich versuche momentan über ein Script meinen Netzwerkdrucker anzusteuern und einen Webscan zumachen und dann das Dokument als *.jpg abzuspeichern.
    Ich habe aber das Problem, dass ich die Variable time nicht nachbilden kann..

    So sieht der Orginal Link aus, welcher aufegrufen wird: http://192.168.1.36/scan/image1.jpg?id=0&type=4&size=2&fmt=1&time=1300308091361

    Entsprechender Javcaode der Seite:

    Code
    var time = (new Date()).getTime();


    Wie kann ich das mit Autoit nachbilden?

    Danke im Voraus für die Hilfe.

    Lg, Fabian

    Einmal editiert, zuletzt von Fabian (16. März 2011 um 22:36)

  • Das sollte funktionieren:

    [autoit]

    Func _Time() ; UNIX timestamp
    ; ProgAndy
    Local $a = DllCall("msvcrt.dll", "uint64:cdecl", "_time64", "uint64*", 0)
    If @error Then Return SetError(1,0,0)
    Return $a[0]
    EndFunc
    MsgBox(0, '', _Time()*1000)

    [/autoit]

    Einmal editiert, zuletzt von progandy (17. März 2011 um 22:24)

  • Vielen Dank progandy.
    Ich werde deine Funktion Morgen einmal ausprobieren.

    Edit:

    Die Funktion alleine funktioniert leider schon nicht.
    Sobald ich dein Beispiel starte, kommt Autoit v3 Script hat ein Problem festgestellt....

    Falls das Betriebssystem wichtig wäre: Windows Vista 32 Bit

    Gruss Fabian

  • Ach ja. Bei x64 gibt es ja nur noch eine Aufrufkonvention, aber für x32 muss explizit cdecl ausgewählt werden. Ich habs korrigiert.

  • Habe nun entlich Zeit gefunden, dass ganze zu erweitern.
    Ich habe das ganze mit WinHttp aus der Hilfe zusammen gebastelt, der Scanner scannt auch, aber ich erhalte kein Bild...?

    Code
    [autoit]

    #include "WinHttp.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)

    [/autoit] [autoit][/autoit] [autoit]

    ; !!!Note that this example will fail because of invalid username and password!!!

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Address
    Global $sAddress = "192.168.1.36",$sData=""

    [/autoit] [autoit][/autoit] [autoit]

    ; Initialize and get session handle
    Global $hOpen = _WinHttpOpen()

    [/autoit] [autoit][/autoit] [autoit]

    ; Get connection handle
    Global $hConnect = _WinHttpConnect($hOpen, $sAddress)

    [/autoit] [autoit][/autoit] [autoit]

    ; Request
    Global $hRequest = _WinHttpOpenRequest($hConnect, _
    "POST", _ ; verb
    "/wsStatus.htm", _ ; target
    Default, _ ; version
    "http://192.168.1.36/wsStatus.htm", _ ; referer
    "*/*") ; accept

    [/autoit] [autoit][/autoit] [autoit]

    ; Send it
    _WinHttpSendRequest($hRequest, _
    "Content-Type: application/x-www-form-urlencoded" & @CRLF, _
    "ws_operation=1&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0")

    [/autoit] [autoit][/autoit] [autoit]

    ; Wait for the response
    _WinHttpReceiveResponse($hRequest)

    [/autoit] [autoit][/autoit] [autoit]

    ; See what's returned
    If _WinHttpQueryDataAvailable($hRequest) Then
    Global $sHeader = _WinHttpQueryHeaders($hRequest)
    ConsoleWrite($sHeader & @CRLF)
    Else
    MsgBox(48, "Error", "Site is experiencing problems.")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _WinHttpCloseHandle($hRequest)
    Global $hRequest = _WinHttpOpenRequest($hConnect, _
    "GET", _ ; verb
    "/scan/image1.jpg?id=0&type=4&size=2&fmt=1&time=1300308091361", _ ; target
    Default)
    _WinHttpSendRequest($hRequest)

    [/autoit] [autoit][/autoit] [autoit]

    _WinHttpReceiveResponse($hRequest)

    [/autoit] [autoit][/autoit] [autoit]

    ; See what's returned
    If _WinHttpQueryDataAvailable($hRequest) Then
    Global $sHeader = _WinHttpQueryHeaders($hRequest)
    ConsoleWrite($sHeader & @CRLF)
    Local $sChunk=""
    While 1
    $sChunk = _WinHttpReadData($hRequest)
    If @error Then ExitLoop
    $sData &= $sChunk
    WEnd
    FileWrite("Local.jpg",$sData)
    ShellExecute("Local.jpg")
    Else
    MsgBox(48, "Error", "Site is experiencing problems.")
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Close open handles and exit
    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

    [/autoit]
    Http Headers

    http://192.168.1.36/wsStatus.htm

    POST /wsStatus.htm HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 75
    ws_operation=1&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0
    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=utf-8
    Cache-Control: no-cache,no-store,must-revalidate
    Accept-Ranges: none
    ----------------------------------------------------------
    http://192.168.1.36/scan/image1.jpg?id=0&type=4&size=2&fmt=1&time=1300308091361

    GET /scan/image1.jpg?id=0&type=4&size=2&fmt=1&time=1300308091361 HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2

    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: image/jpeg
    Cache-Control: max-age=3600, public
    Accept-Ranges: none
    ----------------------------------------------------------
    http://192.168.1.36/wsStatus.htm

    POST /wsStatus.htm HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 75
    ws_operation=0&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0
    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=utf-8
    Cache-Control: no-cache,no-store,must-revalidate
    Accept-Ranges: none
    ----------------------------------------------------------
    http://192.168.1.36/wsStatus.htm

    POST /wsStatus.htm HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 75
    ws_operation=0&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0
    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=utf-8
    Cache-Control: no-cache,no-store,must-revalidate
    Accept-Ranges: none
    ----------------------------------------------------------
    http://192.168.1.36/wsStatus.htm

    POST /wsStatus.htm HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 75
    ws_operation=0&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0
    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=utf-8
    Cache-Control: no-cache,no-store,must-revalidate
    Accept-Ranges: none
    ----------------------------------------------------------
    http://192.168.1.36/wsStatus.htm

    POST /wsStatus.htm HTTP/1.1
    Host: 192.168.1.36
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://192.168.1.36/wsStatus.htm
    Cookie: HPAAWebscan=type%3D4%3Bfmt%3D1%3Bsize%3D2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 75
    ws_operation=0&ws_scanid=0&ws_type=0&ws_format=0&ws_size=0&ws_scan_method=0
    HTTP/1.1 200 OK
    Server: Virata-EmWeb/R6_2_1
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=utf-8
    Cache-Control: no-cache,no-store,must-revalidate
    Accept-Ranges: none
    ----------------------------------------------------------

    Inhalt von Local.jpg

    ÿØÿà( bÑF( AGÖ–’‹E¢€

    SQE€(¢ŠÓBgÿÑú+àfGÂo©Š( aEP ¢ŠNô-#8ïKF(h¤¥ Š( Š( Š( AEP0¢Š(Q@Š( AEP04”´P!(¢Š-%-%i)h ¥¢Š( AEP0¤¥¢€
    (¢€
    JZ(”´RPÑEx¥¤gGásùžI9ýåÕÛ~w2šï½+Ïþ˜Ï…­¼ƒº?:ãiÆ2<ù9
    ôÅb1¬çqHÆ[¿¢ýiãÞ€ tßóÏÿ

    Wo liegt mein Fehler?

  • Du musst WinHttpReadData im Binär-Modus aufrufen, sonst wird an Nullbytes abgeschnitten.

    [autoit]

    Local $bData=Binary(''), $bChunk
    While 1
    $bChunk = _WinHttpReadData($hRequest, 2)
    If @error Then ExitLoop
    $bData &= $bChunk
    WEnd

    [/autoit]

    Oder eben: $bData = _WinHttpSimpleReadData($hRequest, 2)

  • Du musst WinHttpReadData im Binär-Modus aufrufen, sonst wird an Nullbytes abgeschnitten.

    [autoit]

    Local $bData=Binary(''), $bChunk
    While 1
    $bChunk = _WinHttpReadData($hRequest, 2)
    If @error Then ExitLoop
    $bData &= $bChunk
    WEnd

    [/autoit]

    Oder eben: $bData = _WinHttpSimpleReadData($hRequest, 2)

    Vielen Dank, jetzt funktioniert das einscannen.
    Ich werde noch eine GUI und ein paar Optionen einbauen und dann werde ich das komplette Script hier posten.