![]() |
|
#1
|
|||
|
|||
[C] Discarding inputI have two processes (opened in a console window eachone) which cooperate, one of these processes is in waiting status, the other accept an input from a user, then send the input to the first process which elaborate. After these operations the processes exchange the roles between them, the second waits the datas from the second, which accept an input from a user and so on.
Here's the problem, if I write something in the console of the waiting process, it accepts that as input when I should insert the real input. I need to know this, how can I do to discard the input inserted by a user to a process when it's waiting for an input from the other process and not from the user? Sorry for my bad explanation, but I'm not so good with english |
|||
|
#2
|
||||
|
||||
|
OK, let's see if I have this first part:
Quote:
Program B is waiting for input from the user. 1) User enters information. 2) Program B sends that input to program A then waits for info from program A 3) Program A processes the info then waits for user input. Repeat.... Here I lost you. Quote:
2) Which process are you writing something to? 3) What is the definition of "real input" -- from the user or from the other process? Quote:
Quote:
__________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
|
#3
|
|||
|
|||
|
Quote:
5) Program A is waiting for input from the user. 6) User enters information. 7) Program A sends that input to program B then waits for info from program B 8 ) Program B processes the info then waits for user input. Repeat... Quote:
Process B waits for user input Now if I write something in the console of process A (i.e. the input tha I had to give to B) it will be used as input next time that A should accept an in put from user. Quote:
However, I didn't thought about giving focus automatically to one or other console window, how could I do that? |
|
#4
|
||||
|
||||
|
Quote:
I assume you know enough about system programming and documentation to find out how to find the "set focus" function for your system. After all, you found out how to "communicate between processes" and "pause a process awaiting communication" and those are part of the system documentation too... __________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
||||
|
||||
|
Quote:
I don't quite understand yet. You have process A that is waiting for communication from process B. Why is the process A window active and why are you typing into it instead of making process B the active window (SetForegroundWindow or clicking on it) so the keyboard is active in that window? __________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
|
#7
|
|||
|
|||
|
Now the active window is always the windows where I have to write the input, I want to empty the keyboard buffer in order to make the program able to manage every situation. It could happen for some reason that the wrong window is selected by the user.
|
|
#8
|
||||
|
||||
|
Quote:
There isn't a standard way to do this, in fact most compilers can't. __________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
|
#9
|
|||
|
|||
|
I solved with FlushConsoleInputBuffer(hInput);
|
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Receive arrow key input | tay | C++ Forum | 12 | 28-Aug-2008 17:54 |
| IP tables | rogermark100 | C Programming Language | 6 | 18-Apr-2004 07:22 |
| Need Help on checking user input | hihellochao | C Programming Language | 5 | 27-Feb-2004 13:30 |
| Script needed for letting user input a few days of data for tracking and analysis. | tradertt | MySQL / PHP Forum | 3 | 06-Mar-2003 02:54 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The