1. How to avoid windows console with stdin
- Posted by Mike Wever <mewever at hotmail.com> Apr 24, 2006
- 447 views
- Last edited Apr 25, 2006
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.
2. Re: How to avoid windows console with stdin
- Posted by don cole <doncole at pacbell.net> Apr 24, 2006
- 469 views
- Last edited Apr 25, 2006
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
3. Re: How to avoid windows console with stdin
- Posted by Mike Wever <mewever at hotmail.com> Apr 24, 2006
- 441 views
- Last edited Apr 25, 2006
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).
4. Re: How to avoid windows console with stdin
- Posted by don cole <doncole at pacbell.net> Apr 25, 2006
- 447 views
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
5. Re: How to avoid windows console with stdin
- Posted by Mike Wever <mewever at hotmail.com> Apr 27, 2006
- 496 views
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.
6. Re: How to avoid windows console with stdin
- Posted by Larry Miller <larrymiller at sasktel.net> Apr 27, 2006
- 430 views
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
7. Re: How to avoid windows console with stdin
- Posted by Mike Wever <mewever at hotmail.com> Apr 27, 2006
- 437 views
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.
8. Re: How to avoid windows console with stdin
- Posted by don cole <doncole at pacbell.net> Apr 27, 2006
- 425 views
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 }}}
9. Re: How to avoid windows console with stdin
- Posted by ChrisBurch2 <crylex at freeuk.co.uk> Apr 27, 2006
- 421 views
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
10. Re: How to avoid windows console with stdin
- Posted by ChrisBurch2 <crylex at freeuk.co.uk> Apr 27, 2006
- 447 views
Sorry, should have only been one < eu prog < ProgramX Chris
11. Re: How to avoid windows console with stdin
- Posted by Mike Wever <mewever at hotmail.com> Apr 27, 2006
- 449 views
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.
12. Re: How to avoid windows console with stdin
- Posted by don cole <doncole at pacbell.net> Apr 27, 2006
- 424 views
- Last edited Apr 28, 2006
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
13. Re: How to avoid windows console with stdin
- Posted by don cole <doncole at pacbell.net> Apr 28, 2006
- 430 views
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.