Multiple copy and paste thing in Perl

T

TefJlives

Hi all,

For my job, I often have a group of about 10 commands that I need to
type very often. I am thinking that it would be nice to rig up a
program(unless there already is one) where I could enter a bunch of
strings, and then when I press RightControl-r it would enter one
string, then RightContrl-q for another, etc, up to 26 possible
strings. Just like copy and paste, but with many different
possibilities. I thought, if possible, I could make it use the right
control because I never use that key. So, does anyone know if
something like that is doable in Perl? I don't know how to isolate the
right control, I also don't know how to make it paste it where the
cursor is. I have no idea whether this is possible, but if anyone has
any suggestions that would be great. Also, maybe Perl isn't the right
language, but I don't know what is.

Greg
 
T

TefJlives

OK, thanks, I can use shift then.

Greg

As I know to isolate RightControl key is not possible because it is not
handled by hardware. You can detect right or left Shift or Alt but not
Control.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
 
J

Jürgen Exner

TefJlives said:
For my job, I often have a group of about 10 commands that I need to
type very often.

Now, are you talking about 10 commands that you type in a command shell or
10 commands of a programming language the you type in an editor?

In the first case you could simply create an alias (if supported by your
command shell) or write a tiny (shell) script or whatever that executes
those commands.

In the later case any decend text editor has macro capabilities. Just create
a simple text macros, that inserts that piece of program code.
However, if you typing the same lines of code over and over again, then
maybe it would be better to create a subroutine for this part.

jue
 
T

TefJlives

Thanks for your reply. Actually, I should have said strings rather
than commands. It's in windows, too, I should have mentioned. I don't
know how to do any of the things you mentioned in windows. Is Perl the
right language, or should I use something else like C?

Greg
 
J

Jürgen Exner

[Please do not top-post, trying to fix]
Actually, I should have said strings rather than commands.

Ok, so we have established, that some lines of code that you want to insert
one a single button click in your text editor.
It's in windows, too, I should have mentioned. I don't
know how to do any of the things you mentioned in windows.

The operating system has no relevance on how to use or customize your
editor.
Is Perl the right language, or should I use something else like C?

I suggest again to leverage the power of your editor. Why reinvent the wheel
(and probably a wheel with many corners) when adding a macro is a build-in
functionality of your editor already. You didn't mention what editor you are
using, but in any case that would be a question for a newsgroup for your
editor, not for a Perl NG.

jue
 
P

Peter J. Holzer

"TefJlives" <[email protected]> píse v diskusním príspevku
As I know to isolate RightControl key is not possible because it is not
handled by hardware. You can detect right or left Shift or Alt but not
Control.

Sure you can. X11 on Linux reports a keycode of 37 for the left control
key and 109 for the right control key. (I think these are also the scan
codes sent by the hardware, but I may be misremembering things - it's
been about 15 years that I wrote a keyboard driver).

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top