1. How to avoid windows console with stdin

Can anyone tell me a method for reading stdin from within a windows program
without popping up a console window?  I'm able to read other files without the
console coming up, but reading from STDIN seems to cause one to appear.

new topic     » topic index » view message » categorize

2. Re: How to avoid windows console with stdin

Mike Wever wrote:
> 
> Can anyone tell me a method for reading stdin from within a windows program
> without popping up a console window?  I'm able to read other files without the
> console coming up, but reading from STDIN seems to cause one to appear.


Hello Mike,

OK, I give up what's STDIN?

Don Cole

new topic     » goto parent     » topic index » view message » categorize

3. Re: How to avoid windows console with stdin

don cole wrote:
> 
> Mike Wever wrote:
> > 
> > Can anyone tell me a method for reading stdin from within a windows program
> > without popping up a console window?  I'm able to read other files without
> > the
> > console coming up, but reading from STDIN seems to cause one to appear.
> 
> 
> Hello Mike,
> 
> OK, I give up what's STDIN?
> 
> Don Cole

Sorry, I guess I use shorthand sometimes without even realizing it.  I'm
referring to the standard input (file 0).

new topic     » goto parent     » topic index » view message » categorize

4. Re: How to avoid windows console with stdin

Mike Wever wrote:
> 
> don cole wrote:
> > 
> > Mike Wever wrote:
> > > 
> > > Can anyone tell me a method for reading stdin from within a windows
> > > program
> > > without popping up a console window?  I'm able to read other files without
> > > the
> > > console coming up, but reading from STDIN seems to cause one to appear.
> > 
> > 
> > Hello Mike,
> > 
> > OK, I give up what's STDIN?
> > 
> > Don Cole
> 
> Sorry, I guess I use shorthand sometimes without even realizing it.  I'm
> referring to the standard input (file 0).

Hello Mike,

Open a window.

sequence line
fn=open{"yourfile.txt","r")
Open your file and read it, line=gets(fn).

Put the text in your window with, wPuts(yourWindow,line)

Also see get() it may be easier to get it all at once.

Hope this helps.

Don Cole
 A Bug is an un-documented feature.
 A Feature is a documented Bug.
Don Cole

new topic     » goto parent     » topic index » view message » categorize

5. Re: How to avoid windows console with stdin

don cole wrote:
> 
> Hello Mike,
> 
> Open a window.
> 
> sequence line
> fn=open{"yourfile.txt","r")
> Open your file and read it, line=gets(fn).
> 
> Put the text in your window with, wPuts(yourWindow,line)
> 
> Also see get() it may be easier to get it all at once.
> 
> Hope this helps.
> 
> Don Cole
> Don Cole

Thanks for the input, Don, but I guess I'm not communicating my question very
well.  Here is what I am trying to do:

sequence data
data = gets(0)

When I do this from within a windows program (using win32lib), it causes a
console screen to appear, even though I already have a window open.  I want
to avoid the console screen coming up.  Any ideas on that?  Getting the input
from a file other than 0 (standard input) is not an option for this
application.

new topic     » goto parent     » topic index » view message » categorize

6. Re: How to avoid windows console with stdin

By default all windows programs will receive standard input from the console. If
the program does not have a console then the exw interpreter will open one for
you. The exw interpreter will not use a previously opened console. If you are
writing a console application then using exwc.exe would be the way to go. This
interpreter will use an existing console.

You can prevent a console from being opened by first redirecting standard input
to a file. Euphoria does not have a native function to do this but it may be done
with the API function SetStdHandle(), which expects as input a handle to the
desired file. Unfortunately, Euphoria's open() function can not be used to obtain
this handle. open() obtains a private handle that can only be used by the native
Euphoria file functions.

A suitable file handle can be obtained by using the API function CreateFile().
The function is badly named but performs the same function as Euphoria's open().
CreateFile() has many options and can be quite confusing. I haven't used Win32Lib
in some time but I do not believe it has this function.

It seems to me that there must be an alternative to using standard input in this
case. I haven't actually done this but I believe the process outlined is
accurate. If I had a better idea of what you were trying to accomplish I could be
of more help.

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

7. Re: How to avoid windows console with stdin

Larry Miller wrote:
> 
> By default all windows programs will receive standard input from the console.
> If the program does not have a console then the exw interpreter will open one
> for you. The exw interpreter will not use a previously opened console. If you
> are writing a console application then using exwc.exe would be the way to go.
> This interpreter will use an existing console.
> 
> You can prevent a console from being opened by first redirecting standard
> input
> to a file. Euphoria does not have a native function to do this but it may be
> done with the API function SetStdHandle(), which expects as input a handle to
> the desired file. Unfortunately, Euphoria's open() function can not be used
> to obtain this handle. open() obtains a private handle that can only be used
> by the native Euphoria file functions.
> 
> A suitable file handle can be obtained by using the API function CreateFile().
> The function is badly named but performs the same function as Euphoria's
> open().
> CreateFile() has many options and can be quite confusing. I haven't used
> Win32Lib
> in some time but I do not believe it has this function.
> 
> It seems to me that there must be an alternative to using standard input in
> this case. I haven't actually done this but I believe the process outlined is
> accurate. If I had a better idea of what you were trying to accomplish I could
> be of more help.
> 
> Larry Miller

Thanks for the help, Larry.  I'm writing an application to process a text-
only print stream.  Instead of trying to write a printer driver myself, I
am using a program called RedMon which redirects the data from a printer to a
program.  RedMon sends the data via standard output, which is why I am forced
to read the standard input.  I want to have a window come up so the user
knows that the print job has been processed.  I just wish I could get the
console window to stop opening.

My C++ knowledge is pretty basic and I have no experience with the Windows
API, so I'm at the mercy of what win32lib has to offer.

new topic     » goto parent     » topic index » view message » categorize

8. Re: How to avoid windows console with stdin

Hello Mike,

If that's the case try:
procedure onKeyPress(integer self ,integer evebt, sequence parms)
--you can put position here
  wPuts(Window1,sprintf("%s",parms[1]))
end procedure
setHandler(Window,w32HKeyPress,routine_id("onKeyPress"))

Don Cole }}}

new topic     » goto parent     » topic index » view message » categorize

9. Re: How to avoid windows console with stdin

Hi

Chipping in here, some ideas.

Recap (correct me if I'm wrong)

ProgramX -> prints -> new printer port -> redmon grabs this -> sends to
eu prog.

Yes?

Sounds like a redirection problem (look up dos reditrection)

You may haveto put up with a console window appearing, unfortunately.

Possible option 1
Write a batch file with redirection
eu prog << ProgramX
If its a text stream, should be ok.

Possible option 2 
Change the new printer port, which redmon would capture, to print to a file
then set your eu program to monitor file size, then when its stopped increasing
in size, get the input from the file.

Is redmon actualy necessary here?

Note - these are totally untested hypotheses! 

Chris

new topic     » goto parent     » topic index » view message » categorize

10. Re: How to avoid windows console with stdin

Sorry, should have only been one <

eu prog < ProgramX

Chris

new topic     » goto parent     » topic index » view message » categorize

11. Re: How to avoid windows console with stdin

don cole wrote:
> 
> Hello Mike,
> 
> If that's the case try:
> }}}
<eucode>
> procedure onKeyPress(integer self ,integer evebt, sequence parms) 
> --you can put position here
>   wPuts(Window1,sprintf("%s",parms[1]))
> end procedure
> setHandler(Window,w32HKeyPress,routine_id("onKeyPress"))
> 
> Don Cole

That's an interesting solution.  It never occurred to me that the standard
input might set off a KeyPress.  I'll have to try that.

new topic     » goto parent     » topic index » view message » categorize

12. Re: How to avoid windows console with stdin

Mike Wever wrote:
> 
> don cole wrote:
> > 
> > Hello Mike,
> > 
> > If that's the case try:
> > }}}
<eucode>
> > procedure onKeyPress(integer self ,integer evebt, sequence parms) 
> > --you can put position here
> >   wPuts(Window1,sprintf("%s",parms[1]))
> > end procedure
> > setHandler(Window,w32HKeyPress,routine_id("onKeyPress"))
> > 
> > Don Cole
> 
> That's an interesting solution.  It never occurred to me that the standard
> input might set off a KeyPress.  I'll have to try that.

In my way of thinking there are only two ways to get input, from a file or from
the keyboard. If ther's a third way called Standard input them I'm lost here.

Another thought you might also try w32HKeyDown.

Don Cole
 A Bug is an un-documented feature.
 A Feature is a documented Bug.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

13. Re: How to avoid windows console with stdin

don cole wrote:
> 
> Mike Wever wrote:
> > 
> > don cole wrote:
> > > 
> > > Hello Mike,
> > > 
> > > If that's the case try:
> > > }}}
<eucode>
> > > procedure onKeyPress(integer self ,integer evebt, sequence parms) 
> > > --you can put position here
> > >   wPuts(Window1,sprintf("%s",parms[1]))
> > > end procedure
> > > setHandler(Window,w32HKeyPress,routine_id("onKeyPress"))
> > > 
> > > Don Cole
> > 
> > That's an interesting solution.  It never occurred to me that the standard
> > input might set off a KeyPress.  I'll have to try that.
> 
> In my way of thinking there are only two ways to get input, from a file or
> from the keyboard. If ther's a third way called Standard input them I'm lost
> here.
> 

On the other hand if KeyPress and KeyDown don't work maybe you could access you
keyboard buffer in the same manner as above. If that's where Standard input comes
from. And send it to your screen or printer without the console being involved.

Don Cole
 A Bug is an un-documented feature.
 A Feature is a documented Bug.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu