Sign in to follow this  
Followers 0
czmaster

consolewrite NUL char

10 posts in this topic

Hello,

I wan't to write (with consolewrite) the full content of a binary file to output it later with pipe to other app

My problem is that consolewrite end after the firs NUL char. On this forum I read "the ConsoleWrite() function stops reading the string at the first NUL char"

Is there a way to write the NUL (0x00) char with consolewrite (and to continue after this char) ?

I can't not convert the data with binary function or replace some char because it will not work if the content change.

Thank you

Share this post


Link to post
Share on other sites

Why do you need Consolewrite and Pipe to pass it to the other program?

Can't you just run the other program and pass the string using StdInWrite?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The other app can be VLC

With VLC this command play the content of video.avi :

type video.avi | vlc.exe -

type video.avi write the content of the file into console (consolewrite), and with pipe vlc can read it

Can I do the same with StdInWrite ?

I try this code but it doesn't work

Local $foo = Run("vlc.exe -", "..\VLC\", "", $STDIN_CHILD + $STDOUT_CHILD)
$f=FileOpen("video.avi")
$txt=FileRead($f)
StdinWrite($foo,"quit")

Thank you

PS ; My program will not just show a local file but if I can do that the rest

Edited by czmaster

Share this post


Link to post
Share on other sites

You need to pass the full path of VLC.EXE as parameter 1.

Is "VLC" correct as working directory?

I'm not sure you can pass "" as parameter 2. Try keyword Default.

To make sure function Run was called successfully check the value of $foo. If it is 0 then there was an error.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

VLC run and I view its window, sorry

But the stdinwrite code doesn't make a video playing.

May be consolewrite and StdInWrite have the same problem (function stops reading the string at the first NUL char)

Share this post


Link to post
Share on other sites

How about

Local $foo = Run("vlc.exe -", "..\VLC\", "", $STDIN_CHILD + $STDOUT_CHILD)
StdinWrite($foo,"type video.avi")


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

How about

Local $foo = Run("vlc.exe -", "..\VLC\", "", $STDIN_CHILD + $STDOUT_CHILD)
StdinWrite($foo,"type video.avi")

No I don't want to send a command to VLC but a binary stream (type video.avi is a Windows command line function like cat in linux)

I try to to output what stdinwrite write with this code

Local $foo = Run("sort.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$f=FileOpen("video.avi")
$i=0
$txt=FileRead($f)
StdinWrite($foo,$txt)
StdinWrite($foo)
Local $data
While True
$data &= StdoutRead($foo)
If @error Then ExitLoop
Sleep(25)
WEnd
FileWrite(FileOpen("out.txt",2),$data)

And in out.txt, I see only the char before the first NUL char, like consolewrite

On the forum I see this post

In any case, thank you for your help.

Share this post


Link to post
Share on other sites

Why don't you pass the filename to VLC and let VLC process the file?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Because I use a file just to begin and test my code

If this code worked I will do the rest of my code which send stream from internet (protocol that VLC can not read)

But this code doesn't work so I will not continue :(

Share this post


Link to post
Share on other sites

Which protocol do you need to use? VLC can read from a lot of sources.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  
Followers 0