Re: Keyboard Macro Program (as available in Windows)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan,

Thanks for your response!  More interspersed below.

On Sunday 15 September 2002 12:47 pm, Jan Hudec wrote:
> On Sun, Sep 15, 2002 at 09:18:14AM -0400, Randy Kramer wrote:
> > By that I mean a program that will
> > intercept the keystrokes from my keyboard and send a string of
> > keycodes to an arbitrary program.
>
> For console I don't know, but many x terminal emulators definitely
> can do it.
>
> For things you mention, the you need to do it in editor only. Both
> vim and emacs allow you to bind (almost) any key combination
> (including multi-char) to any command or macro. So you want to set
> these in the editor (sure do look for mail client (and similar
> things) that use external editor so you can pick one that can do what
> you want).

Much of my editing is of textareas on Web pages (e.g., a wiki or TWiki) 
-- although a few browsers (text only, like Lynx or links) let you use 
an external editor, the process is rather cumbersome.  Using an 
external editor is not a convenient way to solve my problem.

> > loadkeys:  I can use loadkeys to send a different keycode, but
> > haven't found a way (and don't think there is a way) to send a
> > string of keycodes in response to one keystroke.
>
> This one is lowest level console stuff. It can't do that. But at
> first glance to man page, screen is able to do arbitrary input string
> translations.

But:
   * AFAICT, screen is not used in my Mandrake 8.2 installation
   * My impression (from what you said and my reading of the man page) 
is that it is useful for the virtual consoles only -- I do most of my 
work in X, and therefore want something that works in X


> > expect: From what I've read and tried so far I think:
> >    * Programs like kwrite (just one example) don't accept input
> > from stdin, or send screen output to stdout, so I don't think
> > something like expect, which, IIUC, looks at things on stdout and
> > sends things to stdin, can have any effect on kwrite
>
> No, you have to make difference between terminal-based apps and X
> apps. Mapping keyboard for them is a LOT different matter.

OK, thanks!

> >    * Assuming kwrite could accept input from stdin, I'd really want
> > expect to be sort of a filter on stdin -- look at things coming in
> > on stdin, and replace them with something else if it triggers one
> > of the "expect rules" that I would set up
>
> kwrite is an X app. It recieves input and sends output via the X
> server connection. There is an X input extension, that allows to do
> almost arbitrary transformations on input. So you might even be able
> to do the mapping using xkb or xmodmap maps. However I don't
> understand these too deeply, so I am not sure.

I've started looking at xmodmap (the man pages and so forth) -- nothing 
gives me any hint that I can assign a string (of keys) to a key, but 
your hint is a good one (I think) -- I've joined two xfree lists 
(newbie and expert) and I'll go ask some questions there.  Thanks!

> I bet you don't want the mapping to be universal anyway. 

Well, I would prefer that it be universal -- then I have the freedom to 
change apps at anytime, and it also deals with the problem (mentioned 
above) of editing textareas on web pages.

> You want a
> key to add your signature to work only in your editor and only when
> editing mail. And so on. The more advanced applications (I don't mean
> KDE - it's applications usaly lack powerfull configuration features
> of things like vim or emacs).
>
> > So, I'd like to take a semi-serious look at writing my own program.
> >   (By semi-serious, I mean that I probably don't have the
> > programming skills at this time to actually write the program, but
> > I'd like to attempt to figure out a workable approach and what
> > would be involved.)
>
> I really thing that you can do what you want with screen on console
> and xterms, with xterms themselves in xterms and it may be possible
> with X input extension in X (though I am not sure if it's possible
> with builtin features - but you can have a program to implement it)

Hmm, but would that help me with browsers?  I guess I could start a 
browser from an xterm, and in that case, would any key reassignments I 
made in the xterm take effect in the browser?  I guess I could try a 
test -- reassign a key using xmodmap in an xterm, then start a browser 
from that xterm, and see if the key is reassigned in the browser.  But, 
xmodmap seems like it can only assign a single "keysym" to a keycode 
(ignoring that you can have different assignments for different 
modifiers).

Does screen work on an xterm (and not just on consoles)?  If it did, 
and a change to an xterm can affect a browser started from an xterm, 
maybe that is a way forward.  Ahh, but then I'm still stuck because 
Mandrake doesn't seem to use screen -- I'd have to figure out how to 
install it and make Mandrake work on top of it (I guess).  (The way I 
checked for screen was "ps -Al | grep screen" -- I also tried running 
bindkeys (which I think is the command used to bind keys in screen -- 
it does not exist).)

>
> > In the dos world, one way of writing a program like this is to
> > intercept (hook) the keyboard interrupt, look at the input from the
> > keyboard, and if appropriate, substitute some different input.
> >
> > Anybody know:
> >
> >    * If a similar approach can be followed in Linux?
>
> No. You must intercept it's stdin or X events (both is possible).  

OK, I'll go ask some questions on the xfree lists.

>
> >    * Where to learn more about how Linux handles this type of thing
> > and how I could hook the interrupt in Linux? (Must I dig into the
> > Linux kernel?  Into the whole Linux kernel?)
>
> You can't. It's a really wrong idea. It belongs to user space and is
> possible in user space.

I don't really want to do it in kernel space (I don't think) but I 
would like to do it where it applies universally -- if that can be done 
in X, that would be fine.

> For console - i really thing screen can do it - look at it's man
> page. For X, AFAIK there are pointers to X specifications on
> www.x.org.

I'll try that to (in addition to xfree.org).

> Try to do it in each application using features it provides. You
> seldom find a key binding useful in many contexts. You can't expect
> KDE to be much use here. Learn vim or emacs and use that.

Well just for the record, if kde did implement what I had suggested  
(and konqueror 2.2.2 didn't have a bug that prevents me from editing 
twiki pages with it) something done in kde would be quite useful.  If 
the there were more "buffers" in klipper, and some of them could be 
fixed and include a keyboard shortcut, it would be quite a help.  (Some 
of that may be in kde 3, which I probably won't install until Mandrake 
9.0 is released (as I am too much of a newbie to accomplish that any 
other way, at least the last time I tried)).

Thanks again for your help!  If you (or anyone else) have some further 
thoughts, please let me know.  (I will stay subscribed to this list for 
at least a few weeks, maybe longer.)

regards,
Randy Kramer

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux