Jump to content
Sign in to follow this  
mary

self StdoutRead

Recommended Posts

mary

StdoutRead is used to catch Stdout of an external exe (with Run fonction). But how about catching our Stdout ? I mean read our own console output ?

Why ?

Because some dll (like libcurl) send you result in your Stdout (if you want to not use a callback fonction)

http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

[i]The internal CURLOPT_WRITEFUNCTION will write the data to the FILE * given with this option, or to stdout if this option hasn't been set[/i].

Share this post


Link to post
Share on other sites
jvanegmond

Are you sure it doesn't write to libcurls stdout somewhere?

It is called StdOut for a reason.

Have you tried compiling AutoIt with CUI option and see if the output was really redirected there? Otherwise, maybe start a new process and make that initiate libcurl and read the new process' output.

Edited by Manadar

Share this post


Link to post
Share on other sites
mary

Are you sure it doesn't write to libcurls stdout somewhere?

It is called StdOut for a reason.

when you use it from Scite you can get it in output of scite but when you compile it , there is no way to catch it.

my goal is to get this output in variable ! and not only to see it in a console output

Edited by mary

Share this post


Link to post
Share on other sites
mary

here my code

;#include <String.au3>


; From libcurl headers
Global Const $CURLOPT_URL = 0x2712
Global Const $CURLOPT_WRITEDATA = 0x2711
Global Const $CURLOPT_WRITEFUNCTION = 0x4E2B
Global Const $CURLOPT_PROGRESSFUNCTION = 0x4E58
Global Const $CURLOPT_NOPROGRESS = 0x2B
Global Const $CURLOPT_ERRORBUFFER = 0x271A
Global Const $CURLOPT_TRANSFERTEXT = 0x35
Global Const $CURL_ERROR_SIZE = 0x100
Global Const $CURL_ENCODING=10102
;Global Const $CURLOPT_WRITEHEADER = 0x272D
Global Const $CURLOPT_HEADERFUNCTION = 0x4E6F
Global $source=""
Global $header=""
; Load and initialize curl
$hDll_LibCurl = DllOpen("libcurl.dll")
$hCurlHandle = DllCall($hDll_LibCurl, "ptr:cdecl", "curl_easy_init")
$hCurlHandle = $hCurlHandle[0]



DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_setopt", "ptr", $hCurlHandle, "uint", $CURL_ENCODING, "str", "")


$URL = DllStructCreate("char[256]")

$my_url="http://www.autoitscript.com"

DllStructSetData($URL, 1,$my_url)
DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_setopt", "ptr", $hCurlHandle, "uint", $CURLOPT_URL, "ptr", DllStructGetPtr($URL))

$nPerform = DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_perform", "ptr", $hCurlHandle)

you can download libcurl.dll from http://curl.haxx.se/download.html

Edited by mary

Share this post


Link to post
Share on other sites
toxicvn

here my code

;#include <String.au3>


; From libcurl headers
Global Const $CURLOPT_URL = 0x2712
Global Const $CURLOPT_WRITEDATA = 0x2711
Global Const $CURLOPT_WRITEFUNCTION = 0x4E2B
Global Const $CURLOPT_PROGRESSFUNCTION = 0x4E58
Global Const $CURLOPT_NOPROGRESS = 0x2B
Global Const $CURLOPT_ERRORBUFFER = 0x271A
Global Const $CURLOPT_TRANSFERTEXT = 0x35
Global Const $CURL_ERROR_SIZE = 0x100
Global Const $CURL_ENCODING=10102
;Global Const $CURLOPT_WRITEHEADER = 0x272D
Global Const $CURLOPT_HEADERFUNCTION = 0x4E6F
Global $source=""
Global $header=""
; Load and initialize curl
$hDll_LibCurl = DllOpen("libcurl.dll")
$hCurlHandle = DllCall($hDll_LibCurl, "ptr:cdecl", "curl_easy_init")
$hCurlHandle = $hCurlHandle[0]



DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_setopt", "ptr", $hCurlHandle, "uint", $CURL_ENCODING, "str", "")


$URL = DllStructCreate("char[256]")

$my_url="http://www.google.com"

DllStructSetData($URL, 1,$my_url)
DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_setopt", "ptr", $hCurlHandle, "uint", $CURLOPT_URL, "ptr", DllStructGetPtr($URL))

$nPerform = DllCall($hDll_LibCurl, "uint:cdecl", "curl_easy_perform", "ptr", $hCurlHandle)

you can download libcurl.dll from http://curl.haxx.se/download.html

result :

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.vn/">here</A>.

</BODY></HTML>

why ?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×