473,382 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to simulate keyboard.../dev/tty0?

Hi all,

I'm trying to send chars to the current console (currently having cursor
focus) - /dev/tty0 - in my program by:

my $st = 'K'
my $ri = 'L'
my $ng = 'J'
open(TTY, ">/dev/tty0");
ioctl(TTY, &TIOCSTI, $st);
ioctl(TTY, &TIOCSTI, $ri);
ioctl(TTY, &TIOCSTI, $ng);

I'm using redhat 9, kde.
Everything is ok in the linux console (on tty1 chars are sending
properly - KLJ...), but in kde i see strange things (and not only for
those characters):
^[[D- on ttyp1
- on mozilla window
My question is why chars are not properly sending by ioctl call, is
there any additional settings to do (setting termios, keyboard driver?)??

thanks,
Keeper

Jul 19 '05 #1
1 5523
Keeper <ke****@iosys.no-ip.org> writes:
Newsgroups: alt.perl,comp.lang.perl,comp.lang.perl.misc,comp.l ang.perl.modules
comp.lang.perl does not exist (see FAQ) - please don't start any
threads there. Nobody will see your message there except the clueless
and those of us who periodically visit from comp.lang.perl.misc to
rescue the clueless.

Please don't cross-post alt.perl and comp.lang.perl.* - the people who
hang out in alt.perl tend to do so because they found comp.lang.perl.*
"unfriendly". (Actully, they usually found it to be intollerant of
selfishness). Duping these people into posting to comp.lang.perl
won't make either them or us happy.

By definition comp.lang.perl.misc is for stuff that doesn't have a
more specific home in comp.lang.perl.*. As such it is very rarely
appropriate to cross-post comp.lang.perl.misc and another
comp.lang.perl.* group.
my $st = 'K'
my $ri = 'L'
my $ng = 'J'
open(TTY, ">/dev/tty0");
ioctl(TTY, &TIOCSTI, $st);
ioctl(TTY, &TIOCSTI, $ri);
ioctl(TTY, &TIOCSTI, $ng);

I'm using redhat 9, kde.
Everything is ok in the linux console (on tty1 chars are sending
properly - KLJ...), but in kde i see strange things (and not only for
those characters):
^[[D- on ttyp1
- on mozilla window
My question is why chars are not properly sending by ioctl call, is
there any additional settings to do (setting termios, keyboard
driver?)??


Your question has nothing whatever to do with Perl. Whatever the
answer it would be exactly the same whatever language you used to
issue those ioctl()s.

IIRC the X server puts the tty device into a mode where keys generate
hardware specific scan-codes not ASCII(-like) codes. If you wish to
put keys into the tty keyboard stream that goes to the X server then
you'd need to use scan-codes. There are also mechanisms to inject
events into X but I don't know anything about them.

(Like I say I'm not an expert on this - but then if you are looking
for experts on this you are in the wrong place).

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael J Whitmore | last post by:
Greetings, I have a very simple question. How do you simulate a user input to turn off a screen saver in Windows (either a mouse movement, mouse click, or keyboard input)? I promise I searched...
2
by: Keeper | last post by:
Hi all, I'm trying to send chars to the current console (currently having cursor focus) - /dev/tty0 - in my program by: char st='K',ri='L',ng='J'; int tty; tty = open(">/dev/tty0",...
1
by: Keeper | last post by:
Hi all, I'm trying to send chars to the current console (currently having cursor focus) - /dev/tty0 - in my program by: char st = 'K', ri = 'L', ng = 'J' int tty; tty = open(">/dev/tty0",...
0
by: Mythran | last post by:
I'm trying to create a library that will 1.) Simulate an input device (IE: keyboard, mouse, joystick) and 2.) Capture data sent from an input device (IE: keyboard, mouse, joystick). The reason's...
3
by: John Dalberg | last post by:
I have an app that keeps popping up a windows with a 'Yes' or 'OK' button on it. I am trying to write a little app that automates hitting the enter key so I don't have to do it myself. I used...
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
3
by: =?Utf-8?B?cHJvZ2dlcg==?= | last post by:
I have a C# application that hosts an AxWebBrowser control which I automate by sending mouse clicks and keyboard input. I have had various problems in doing this due to a bug in the AxWebBrowser...
2
by: Brice Rebsamen | last post by:
Hi I wrote the following program that reads the keyboard in medium raw mode (keycode mode). Here is the initialization code, the full code is at the end. fd = open("/dev/tty0", O_RDONLY);...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.