Jump to content

Capture/Get from Console


Recommended Posts

Hello my teachers and friends,
Wen I run a program:

Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText)

I receive a console as result.
But i don't like console, i use:

Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE)

Okay, very good. But i need a msgbox is contained from console or can you show me: how to create a log.txt - this file has content of console.
Thank you so much. 
P,s
Dear Mr. Melba23

How are you?
Can you help me?

Edited by anhyeuem
Link to comment
Share on other sites

Hi,

Take a look at StdoutRead in the helpfile.

Br, FireFox.

oh, thank you so much, my friends

StdoutRead vs StdErrRead : i have just read it and i don't understand 100%

I am also newbie at autoit

Can you show me more and more

thanks

Link to comment
Share on other sites

It's not related to autoit, you can find on internet the difference between them.

The standard output corresponds to ConsoleWrite and standard error corresponds to ConsoleWriteError in autoit.

The developer chooses to wether write in one of them, depending on wether it's an information or an error.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

It's not related to autoit, you can find on internet the difference between them.

The standard output corresponds to ConsoleWrite and standard error corresponds to ConsoleWriteError in autoit.

The developer chooses to wether write in one of them, depending on wether it's an information or an error.

Br, FireFox.

Thank you for reply.

Okay, i am going search from google and read them.

With me: a pupil 12 age, it is very difficult. 

this is a exam, a my homework from teacher.

I need example then try and i will understand.

Link to comment
Share on other sites

Hi anhyeuem

also, try this

(note that this will work only if your program, that is contained in the $a variable, will allow I/O redirection....)

#include <Constants.au3>

Local $dos_output = "" ; declare a variable to get output

; execute your program hidden and with output redirected
Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDOUT_CHILD)

; Local $cmd = Run("ping localhost", "", @SW_HIDE, $STDOUT_CHILD) ; this is a working example

While Not @error ; wait the end of your program
    $dos_output &= StdoutRead($cmd) ; get the output from your program while is running
WEnd

MsgBox(0, "", $dos_output) ; display the final output of your program

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

 

Hi anhyeuem

also, try this

(note that this will work only if your program, that is contained in the $a variable, will allow I/O redirection....)

#include <Constants.au3>

Local $dos_output = "" ; declare a variable to get output

; execute your program hidden and with output redirected
Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDOUT_CHILD)

; Local $cmd = Run("ping localhost", "", @SW_HIDE, $STDOUT_CHILD) ; this is a working example

While Not @error ; wait the end of your program
    $dos_output &= StdoutRead($cmd) ; get the output from your program while is running
WEnd

MsgBox(0, "", $dos_output) ; display the final output of your program

oh, this is perfect. Almost pupils from my shool are reading and using this code. They are talking and comment.

But my friend:

$a = (GUICtrlRead($hFileInput))

$hFileInput = GUICtrlCreateInput( "", 19, 33, 474, 19)...

$t ...$szText : they are like $a:  GUICtrlCreateInput

-> your code don't show content of console.

can you help me

Edited by anhyeuem
Link to comment
Share on other sites

 

Hi anhyeuem

also, try this

(note that this will work only if your program, that is contained in the $a variable, will allow I/O redirection....)

#include <Constants.au3>

Local $dos_output = "" ; declare a variable to get output

; execute your program hidden and with output redirected
Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDOUT_CHILD)

; Local $cmd = Run("ping localhost", "", @SW_HIDE, $STDOUT_CHILD) ; this is a working example

While Not @error ; wait the end of your program
    $dos_output &= StdoutRead($cmd) ; get the output from your program while is running
WEnd

MsgBox(0, "", $dos_output) ; display the final output of your program

If i use:

 

Local $cmd = Run("ping localhost", "", @SW_HIDE, $STDOUT_CHILD) ; this is a working example

it is very good, by my case, it can't not show

very poor my friend

Link to comment
Share on other sites

what is the program that you want to run?
(what is the content of the $a variable?)

edit:

....I had not seen the post # 7 sorry

Edited by PincoPanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

what is the program that you want to run?

(what is the content of the $a variable?)

I run signtool.exe with parameter

do you have teamviewer software?

myid: 433 082 431

pass: h353gx

-> you can see my computer and you will understand them

Link to comment
Share on other sites

what is the program that you want to run?

(what is the content of the $a variable?)

#include <Constants.au3> 
Local $dos_output = "" ; declare a variable to get output
$a = "C:\test\signtool.exe"
$t = "http:/google.com"
$f = "C:\test\mycert.pfx"
$p = "password"
$szText =  = "C:\test\test.exe"
Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDOUT_CHILD) 

While Not @error ; wait the end of your program     $dos_output &= StdoutRead($cmd) ; get the output from your program while is running WEnd MsgBox(0, "", $dos_output) ; display the final output of your program 

-> very good my friend

it can show very good

But my case: i create GUICtrlCreateInput

...
$hFileInput = GUICtrlCreateInput( "", 19, 33, 474, 19)
...
$a = GUICtrlRead($hFileInput)
$t = GUICtrlRead($hTime)

...

-> not show :((
Edited by anhyeuem
Link to comment
Share on other sites

I do not know the signtool.exe program, and I do not know if it allows I/O redirection,

anyway you could try to change $STDOUT_CHILD with $STDERR_MERGED instead

in this way you could see also error messages coming from that dos program.

(always if it allows i/o redirection....)

Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDERR_MERGED)

p.s.

I do not recommend putting passwords online .... 

EDIT

corrected $STDERR_MERGED

Edited by PincoPanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I do not know the signtool.exe program, and I do not know if it allows I/O redirection,

anyway you could try to change $STDOUT_CHILD with $STDERR_MERGED instead

in this way you could see also error messages coming from that dos program.

(always if it allows i/o redirection....)

Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDERR_MERGED)

p.s.

I do not recommend putting passwords online .... 

EDIT

corrected $STDERR_MERGED

Dear my friend

all pupil from my school want to say: "thank you so much"

 

#include <Constants.au3> 
Local $dos_output = "" ; declare a variable to get output
$a = "C:\test\signtool.exe"
$t = "http:/google.com"
$f = "C:\test\mycert.pfx"
$p = "password"
$szText =  = "C:\test\test.exe"
Local $cmd = Run($a & " a" & " /t " & $t & " /d " & $d & " /du " & $du & " /f " & $f & " /p " & $p & " /v " & $szText, "", @SW_HIDE, $STDOUT_CHILD) 

While Not @error ; wait the end of your program     $dos_output &= StdoutRead($cmd) ; get the output from your program while is running WEnd MsgBox(0, "", $dos_output) ; display the final output of your program

Code above is okay, we use it for our homework.

But can you tell me why?

Run: okay but Runwait: don't show msgbox ????

 

Link to comment
Share on other sites

Dear my friend

all pupil from my school want to say: "thank you so much"

 

 

You are welcome :)

Code above is okay, we use it for our homework.

But can you tell me why?

Run: okay but Runwait: don't show msgbox ????

 

 

I think because RunWait stops the execution of your main script untill the exe program has finished

so in this way you can not grab his output,

but also because, according to the help file, RunWait does not allows Output redirection and so you can't pipe the output of the executed program to your scrpt. (this is obvious, because if the main program stops untill the launched exe has finished, then there is no way to control it in the while....)

bye :bye:

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...