Results 1 to 6 of 6
Does one can help?...
- 08-22-2009 #1Just Joined!
- Join Date
- May 2008
- Posts
- 14
How do i simulate CTRL + A key press in c?
Does one can help?
- 08-31-2009 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- Canada
- Posts
- 109
Hi
The CRTL A, which has an ascii control key equivalent, is the ASCII characters 'SOH' (not including the quotes) which stands for Start Of Header. Its Decimal equivalent is 01, its HEX value is also 01 (prefaced by the appropriate identifier) and its binary value is 00000001 (No Parity). My C is a bit rusty but you should be able to write a two or three line C program, using the fprintf(stdout,\01) or the printf function and play around a bit to get it to produce the effect you are looking for. Not sure if this will help. Cheers...
Robert
- 08-31-2009 #3
You might be interested in following thread
http://www.linuxforums.org/forum/lin...-handling.html- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 09-02-2009 #4
The answer to your question depends a lot on where you want to simulate a CTRL-A keypress. Simulating a keypress in an X Window app is a lot different from simulating a keypress in a terminal application...
For instance: if you were dealing with a program which takes all its input from stdin, you could simulate a keypress to that program by simply redirecting its standard input when you run the program, to a source which you control... For a simplistic example this could be like "echo -e '\001' | program"
If you were dealing with a program which takes its input from /dev/tty (a real "terminal application" as opposed to a strict stdio application) - then you would have to use ioctl() and TIOCSTI to simulate an input character on that TTY.
If you were dealing with an X app, then I don't know the answer exactly - I think you'd have to generate keyboard events and dispatch them to the application in question.
- 09-03-2009 #5Just Joined!
- Join Date
- Dec 2007
- Location
- Bangalore >> India
- Posts
- 28
Have a look this post , It May help you
- 09-03-2009 #6


Reply With Quote
