redirect printf to stdin of aother program [without pipes]

adfm's Avatar, Join Date: Apr 2006
Newbie Member
Hello all,

I have a particular problem to solve. I need to redirect a printf of a program to the stdin of the "system".

I do not want to pipe the stdin as a child of another program. What I want to do is "simply" override the keyboard and allow any application that has the system focus to catch the printf of my application as a simple keyboard input.

How can I do this (without pipes)?

cheers
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Why do you want to do it without pipes, which would seem the logical way to solve this?
0
adfm's Avatar, Join Date: Apr 2006
Newbie Member
Well, I need it to be application independent. By using pipes I would need to change all applications that may be targets... Which isn't feasible.

The idea is to have an application that writes to the keyboard buffer, which in turn will be understood as the application that as the focus as the input of any user that is typing the keyboard.

Cheers
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Probably we're talking about different kinds of pipes. I'm thinking of the vertical bar pipe, i.e. dir | sort, which is implemented at the command line and requires no application modification. The command dir | sort sends the dir output to sort input and the output is a sorted directory (which in its basic form isn't a lot of use because most dir commands include some sorting options anyway, but if sort implements a type of sort that dir doesn't, then this becomes useful).
0
adfm's Avatar, Join Date: Apr 2006
Newbie Member
My problem is more complex than that.

I don't want to redirect raw data from one application to another. What I need is to write an application that writes to the keyboard buffer so that I don't have to explicitly pipe two apps.

The problem is this. I'm developing a program that will be used along a number of unrelated programs. The idea is to have my application running as a process in background and when something happens it will write to the keyboard buffer and the application that has the focus will catch the keyboard input. For instance an input box of an app will catch the keyboard input of the other. The pipes would only solve my problem if:

1) I would code both applications to pipe them together as father\son (not the case)
2) If the second application would just be a simple application that would receive something and handle it (which wont be in most cases).

I was looking at writing an ISR, but that seems like an overkill to me!

Any ideas everyone?!

Cheers
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
What operating system are you using?
0
adfm's Avatar, Join Date: Apr 2006
Newbie Member
I'm writing for Linux for starters.

I know that most likely any implementation wont be portable, so, I'm coding for linux for now.

I know that for windows I could use VB of C# SendKey function, but my main concern for now is Linux.

Cheers