maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Xterm Command Typer and Form Filler (https://talk.maemo.org/showthread.php?t=19365)

GeraldKo 2008-04-21 16:05

Xterm Command Typer and Form Filler
 
Wouldn't it be great to be on your NIT in Xterm, tap a single button at the $ prompt, and have

Code:

sudo gainroot
typed in for you automatically?

Or to tap a single button and have typed:

Code:

/user/home/media/mmc2/myfiles/music
Or click on a button called "fsck" and get:

Code:

fsck -fy /dev/mmcblk0p2
That is, wouldn't it be great to have a macro-typing applet that could enter your most used commands (or parts of commands) automatically in Xterm?

Similarly, in MicroB (or Links2), wouldn't it be great to have a form-filler, that is, a macro-typing-tool that, faced with a form, could fill in stuff like email addresses and street addresses. If the tool also had password protection and the ability to understand <<tabs>> and <<returns>>, it could securely store and automatically fill in, say, your email address and (automatically including a tab and return) your password; or your log-in; or it could fill in your complete name-and-address, with proper formatting, with one click of a button.

Well, such a macro-typer exists for Windows and this is a plea to programmers to make one for Maemo. A key part of what makes this applet so great is that it is always-on-top, but enters the characters wherever the cursor is in the next window down. And it can be quickly minimized to the task bar. (On a Tablet it would ideally minimize to the status bar.)

The Windows applet is called TypeItIn. You can download an old freeware version of it here. The current version is substantially more powerful and is available here as shareware. That website also provides a good description of it.

Here is a screenshot:

http://i248.photobucket.com/albums/g...tInLinus-1.jpg

In the panel I made up for this screenshot (the current version allows you to switch among various panels and to decide which of those to password-protect), you could, for example, click "Complete Address" and it would type:
Code:

Linus Torvalds
512 Iamagodthegoodkind Strasse
Helsinki, Finland TW53H

or you could click on the button named "fsck" and it would type:

Code:

fsck -fy /dev/mmcblk0p2
Any takers? Please??

(If this looks familiar, it's because I'd tried to arouse interest in such a project once before. Rbrewer123 and Benson posted some ideas there that might be useful.)

konus 2008-04-21 16:18

Re: Xterm Command Typer and Form Filler
 
Code:

$ echo "alias music='cd /user/home/media/mmc2/myfiles/music'" > $HOME/.profile
or use Command navigator :)

GeraldKo 2008-04-21 19:55

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by konus (Post 172628)

Happy to try it, thanks! (Didn't know it typed macros.)

Since the author says,

Quote:

Although the author still finds Command navigator useful, there exists a more feature-rich applet (based on Command navigator), Personal menu. Thus, the development of Command navigator is discontinued–it receives only bugfixes.
do I need Command Navigator or does Personal Menu offer that functionality, too?

geneven 2008-04-21 20:02

Re: Xterm Command Typer and Form Filler
 
This is nice, but my current Xterm supports Sudo Gainroot with a single click and apt-get update with a single click. I just used the settings available now. I could create more, but these are the ones I use most.

Benson 2008-04-21 20:12

Re: Xterm Command Typer and Form Filler
 
Well, with xte, anything that runs commands can do it; so any of Personal Menu, CmdNav, osso-statusbar-cpu, powerlaunch, and probably others will do. Trouble is, they don't give you the always-on-top window you want, so you have to launch them with the panel, or with the power button, in the case of powerlaunch.

fiferboy 2008-04-21 20:14

Re: Xterm Command Typer and Form Filler
 
Personal Navigator will allow you to launch command in xterm, but there is an annoying bug with xterm which opens two window when doing this. I don't think there is anyway to get it to type text in a currently open xterm.

GeraldKo 2008-04-23 20:43

Re: Xterm Command Typer and Form Filler
 
Thanks all for the Command Navigator/Personal Menu recommendation. Personal Menu is a great app, much better than my old Simple Launcher.

HOWEVER, it still leaves me wanting a macro typing tool. It would be such a boon for the tablet. Here is fiferboy's reply to my question about using Personal Menu for form filling (fiferboy is PM's creator):

Quote:

GeraldKo: If you could find a macro program that would do that, you would be able to launch the macro from personal menu. I don't know of any macro typers for Maemo, but if you find a good, lightweight Linux one there is a possibility of a port.
So, I'm still looking for takers! I swear, if you have a Windows box to try out TypeItIn, you'll be delighted about what a great time-and-hassle-saver it can be. Especially when you don't have a full-size keyboard handy. (Like when you're traveling light with your NIT and need to fill in all this hotel reservation info, when you're shopping online ... )

(I'm thinking about making some comments here about the iPod Touch and how it compares to the NITs, just to keep the thread alive until some developer gets the bug to code a macro typing tool. :) )

qwerty12 2008-04-23 20:48

Re: Xterm Command Typer and Form Filler
 
You could make an xkbd layout that.would type in leters with a single buttons.

GeraldKo 2008-04-24 03:19

Re: Xterm Command Typer and Form Filler
 
Starting with fiferboy's advice,
Quote:

I don't know of any macro typers for Maemo, but if you find a good, lightweight Linux one there is a possibility of a port.
I've been trying to find a Linux macro typer. And I've had some success, but Linux coders/users would be better able than me to assess them.

1. First, there's Snippits. I have a feeling this is the most developed but is problematic since it "can work from any system that supports the Ruby programming platform." Does that kill it for maemo purposes? Or is that a good thing? Here's a Lifehacker article called "Automate Repetitive Typing with Snippits.". It includes this YouTube video of Snippits in action. Snippits has some weird, extra capablities, like it can grab info from the internet and put it in with what you're typing. It can also automatically enter formatted dates, times, etc. FWIW, here's a How-To thread on ubuntuforums.

2. Next, and good since it's Python-based, is Autokey. "It listens to keyboard events on /dev/input/eventX and uses the python-xlib library to send xtest events to drive the expansions." It, too, has a YouTube video and an example abbr.ini file.

3. There are various Firefox add-ons, which would need porting to MicroB. I like the idea of an applet that can automatically enter text in any maemo program, but a MicroB browser add-on would address most needs. I need to test these still, but the obvious ones seem to be: Clippings, Fireform, and Formfiller.

GeraldKo 2008-04-24 03:24

Re: Xterm Command Typer and Form Filler
 
Post #9, directly above, is much more important than this one, but I couldn't resist ...

Doing my research for the preceding post, I came across plenty of Linux users wishing there were an automatic-text-entering tool like TypeItIn. For example:


"i've just spent the last hour searching many linux software sources. i'm looking for a program where i can set up keyboard shortcuts that will enter text strings into various applications. under windows there is typeitin, and also a utility made by pc magazine called robotype. anyone recall seeing something similar?"

"I am trying to find an application that i can use to send keystrokes to other applications.
For example in windows i used to use a program called typeitin "

"TypeItIn lets you define buttons that will insert any information you
want in any Windows application ...
Is there a Linux equivalent?"

"The one Windows ap I cannot live without is a little one that saves
phrases of indefinite length and lets you insert one you select by
clicking on one of an indefinite number of buttons.
And it works with any application!
Is there something like that for Linux?"

Benson 2008-04-24 03:33

Re: Xterm Command Typer and Form Filler
 
gxmessage + xte FTW?
I don't have time to rig it up right now, but it's really trivial.
Only suboptimal bit is launching....

geneven 2008-04-24 03:33

Re: Xterm Command Typer and Form Filler
 
I learned about the power of macros back in the 1980s or so with version 4 something (4.23, my mind suggests!) of WordPerfect, and they certainly were handy. In a tablet they would be more handy than ever because typing is more difficult than with a full-fledged keyboard. What caused me to be less enthusiastic about this idea is that it was said to be primarily needed for typing in an xterm. I don't want it for typing in an xterm; I want it for typing in Notecase or other cool programs that we already have that could clearly be enhanced by macros.

There is, for example, an excellent web-based mind-mapping program called Mindmeister. It works pretty well on my N800, but a few key-hits are not available because they involve Ctrl keys or other keys the N800 doesn't have. So, I rarely use it on my N800. Macros would probably transform the Mindmeister experience.

GeraldKo 2008-04-24 03:44

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by geneven (Post 173920)
In a tablet they would be more handy than ever because typing is more difficult than with a full-fledged keyboard.

Esactly!

Quote:

Originally Posted by geneven (Post 173920)
What caused me to be less enthusiastic about this idea is that it was said to be primarily needed for typing in an xterm. I don't want it for typing in an xterm; I want it for typing in Notecase or other cool programs that we already have that could clearly be enhanced by macros.

I guess it was bad marketing on my part! (Maybe I should start with a new thread with a different title.)

Quote:

Originally Posted by geneven (Post 173920)
There is, for example, an excellent web-based mind-mapping program called Mindmeister. It works pretty well on my N800, but a few key-hits are not available because they involve Ctrl keys or other keys the N800 doesn't have. So, I rarely use it on my N800. Macros would probably transform the Mindmeister experience.

Yup!

(And, by the way, Geneven, for the past three weeks I've been using this trick, too, to autotype "sudo gainroot" in Xterm.)

GeraldKo 2008-04-24 03:46

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by Benson (Post 173919)
gxmessage + xte FTW?
I don't have time to rig it up right now, but it's really trivial.
Only suboptimal bit is launching....

Huh, what? (OK, I can wait until you have time for me to find out what you're talking about!)

Benson 2008-04-24 09:51

Re: Xterm Command Typer and Form Filler
 
gxmessage does dialog boxes from a script; xte pushes key events through the X server with xtest. (Naming is a bit of cleverness; it's the successor to xse (X send event) which was pre-xtest.)

Benson 2008-04-24 15:41

Re: Xterm Command Typer and Form Filler
 
Script:
Code:

#!/bin/sh
pages=3
page=0
pagestem=/home/user/.menuizer/page
if [ "x$1" != x ] ; then
  page=`expr "$1" % $pages`
fi
while true ; do
  response=`gxmessage -center -borderless -nofocus -print -buttons "$(cat $pagestem$page)"',\\\\/,/\\\\' ""`
  case "$response" in
    '\/')
      page=`expr \( $page + 1 \) % $pages`
      ;;
    '/\')
      page=`expr \( $page + $pages - 1 \) % $pages`
      ;;
    *)
      break
      ;;
  esac
done
#echo $response
xte "str $response"

Make files of the form $pagestem$page, where page ranges from 0 to $pages - 1. Each one looks like
Code:

string1,string2,string3
with as many strings as will fit on the screen (experiment).
This can also be converted to use a list, but then you'd have to select an entry and then click OK. I thought this was better.

As I said before, the trouble is launching it; since I can't make it always-on-top (and since it's huge), I can't just make it respawn itself; powerlaunch is going to be the quickest, most generally available way of launching it, but that's not very friendly. All the other obvious solutions rely on not having the foreground window fullscreened.

Edit: it is always-on-top... Attempt at reducing screen footprint and looping coming right up.

GeraldKo 2008-05-13 03:05

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by Benson (Post 172763)
Well, with xte, anything that runs commands can do it; so any of Personal Menu, CmdNav, osso-statusbar-cpu, powerlaunch, and probably others will do. Trouble is, they don't give you the always-on-top window you want, so you have to launch them with the panel, or with the power button, in the case of powerlaunch.

I don't think the always-on-top feature would be that important if it could be launched from Personal Menu: You launch it with Personal Menu, click the character-string-generating button you want, move your cursor to the next place you want the typing, launch it again with Personal Menu, click the next button you want.

Quote:

Originally Posted by Benson (Post 174109)
Attempt at reducing screen footprint and looping coming right up.

Any progress?

Benson 2008-05-13 16:42

Re: Xterm Command Typer and Form Filler
 
Well, that only works if you're not running fullscreen... Else there's non-trivial cost to launching it. So I was thinking a persistent, always-on-top window would be best.

Oh, that attempt... Sorry to leave you in suspense; it was an utter flop. What's there is the best you're gonna get by this approach. Did you try it?

Personally, if I wanted this kinda thing, I'd be inclined to use Personal menu for regular menu stuff, and stack command-navigator full of typing shortcuts like this:
Description: Foo
Command: xte 'str Foo'

GeraldKo 2008-05-13 17:28

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by Benson (Post 181117)
Well, that only works if you're not running fullscreen... Else there's non-trivial cost to launching it. So I was thinking a persistent, always-on-top window would be best.

Oh, that attempt... Sorry to leave you in suspense; it was an utter flop. What's there is the best you're gonna get by this approach. Did you try it?

Personally, if I wanted this kinda thing, I'd be inclined to use Personal menu for regular menu stuff, and stack command-navigator full of typing shortcuts like this:
Description: Foo
Command: xte 'str Foo'

I'd be happy to do this out of Personal Menu. By "command-navigator" do you just mean the part of Personal Menu where you add "Name of the menu entry:" and "Command to execute:" -- or do I need something in addition to PM, like the old Command Navigator?

In PM, I entered
Code:

Hello
in "Name of the menu entry:" and
Code:

xte 'str Hello'
in "Command to execute:"

From Run As Root, nothing happens. From Run In Terminal, I get
Code:

sh: xte: not found
With neither checked, I get a notice Execution Failed.

I don't know what xte is, but I don't see it in installed or installable applications, nor in gronmayer repositories.

So, if you'd be so kind, I could use some education. Thanks!

Benson 2008-05-13 17:52

Re: Xterm Command Typer and Form Filler
 
I mean the old command navigator; I'm running both, so I get two menus. (One 40px, for friendly fingers, and the other (cmd-nav) packed closer.) But if you only want to run one, then you can certainly do it all in P-menu. (And you seem to be doing it right.)

xte is from Xautomation, I had thought I linked that previously. I'll go find it... [/url]http://www.internettablettalk.com/forums/showthread.php?t=18132&page=2]Here it is[/url]! Download the .tgz, extract it somewhere, and do what you like. ;) I copied (as root, of course) the xte binary to /usr/bin or some such. You could probably also (if not running low on space, and scared like I was at the time) just 'make install' (root, again) from the xautomation-1.02 directory. I recommend that approach, but warn that I did not try it...

The xte command doesn't need to be run as root, and as you can see, that masks some feedback, so don't run as root unless needed...


As for "what xte is", well, it's a program that stuffs keystrokes (or other events) into an X server. I think you did know what it is, after all... Now you know how to get it.

GeraldKo 2008-05-13 20:58

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by Benson (Post 181148)
I mean the old command navigator; I'm running both, so I get two menus. (One 40px, for friendly fingers, and the other (cmd-nav) packed closer.) But if you only want to run one, then you can certainly do it all in P-menu. (And you seem to be doing it right.)

xte is from Xautomation, I had thought I linked that previously. I'll go find it... [/url]http://www.internettablettalk.com/forums/showthread.php?t=18132&page=2]Here it is[/url]! Download the .tgz, extract it somewhere, and do what you like. ;) I copied (as root, of course) the xte binary to /usr/bin or some such. You could probably also (if not running low on space, and scared like I was at the time) just 'make install' (root, again) from the xautomation-1.02 directory. I recommend that approach, but warn that I did not try it...

The xte command doesn't need to be run as root, and as you can see, that masks some feedback, so don't run as root unless needed...


As for "what xte is", well, it's a program that stuffs keystrokes (or other events) into an X server. I think you did know what it is, after all... Now you know how to get it.

You might be surprised how long it takes a newbie to do some of these things! :eek: But, I'm getting there!

At this point I have an xautomation folder (post-gunzipping-and-tarring) in my /usr/bin/ folder. I went into the folder in Xterm, as root, and tried doing this
Code:

# ./configure
# make
# make install

but it said, after lots of other messages, that there was no acceptable C compiler in $PATH. Then I just tried
Code:

make install
but it said
Code:

/bin/sh: make: not found
So, now that I have the files untarred (or is it tarred?) in a folder in /usr/bin/, what might I do next to get to where xte is a meaningful command? (Thanks again.)

Benson 2008-05-13 21:13

Re: Xterm Command Typer and Form Filler
 
Good instincts, but this time you don't want ./configure and make; the program is already built, so they're unnecessary.
Obviously, you need to have make installed for that plan to work; I do, but evidently it's not default (as I had assumed it was)...

I guess falling back to manually copying the one binary needed is sanest at this point.

So if I'm reading you right, you have everything in /usr/bin/xautomation-1.02/ ? That's not where I'd have put it, but it'll do. ;)

What you want to wind up with is just the file xte in /usr/bin.

So, assuming it's in /usr/bin/xautomation-1.02/, do something like
Code:

cd /usr/bin/xautomation-1.02/
cp xte /usr/bin/

and, optionally,
Code:

cd
rm -r /usr/bin/xautomation

to remove the source and other programs afterwards.

GeraldKo 2008-05-13 23:59

Re: Xterm Command Typer and Form Filler
 
Well, Benson, I'm getting there. All that stuff for just one little file? I took your advice and moved everything but xte out of /usr/bin/. After a while I'll delete it.

So far I would swear that xte's output is partially random. Your basic idea is being vindicated to my satisfaction. Next I have to get better at xte. I mean it though, xte seems to have a mind of its own. I put in a command or whatever you call it that follows xte in "Command to execute:" in PM. The string has uppercase and lowercase letters, but xte will type only the capital letters. Later I try adding a keystroke for a return. That doesn't work, but after I remove it and go back to exactly the command that I previously had, it starts typing both upper- and lower-case letters.

Then I put in a different command (a key shift), but instead of doing what I want, xte goes crazy and keeps typing spaces -- it would type spaces no matter what was open; it seemed there was no way to stop it except by shutting down.

Then I go back to what I last had, but now it refuses to type anything but uppercase again. (Actually, what it does is ignore all lower-case input while outputting a lower-case letter for each upper-case character in the requested string!)

So, I have more work to do on xte, but it looks like you got me on the track I was asking for.

As Arnold would say, I'll be back.

Benson 2008-05-14 00:06

Re: Xterm Command Typer and Form Filler
 
With str, it tries to translate a string into key press (and release) events. If you're having trouble with that, you could try to run individual keys, giving you more direct control...

But it was working fine for me; the exact example shown typed Foo quite nicely. <shrug \>

There's a man page here:
http://linux.com.hk/penguin/man/1/xte.html

HTH

GeraldKo 2008-05-14 02:08

Re: Xterm Command Typer and Form Filler
 
Quote:

Originally Posted by Benson (Post 181318)
With str, it tries to translate a string into key press (and release) events. If you're having trouble with that, you could try to run individual keys, giving you more direct control...

But it was working fine for me; the exact example shown typed Foo quite nicely. <shrug \>

There's a man page here:
http://linux.com.hk/penguin/man/1/xte.html

HTH

Well, when I use your Foo command, I just get f (since the F in Foo was uppercase, it gets printed lowercase, and the lowercase o's get ignored).

But I've made the macros I want, and I'm a happy camper. If I want, say, "Gerald Ko", I use:
Code:

xte 'key Shift_L' "str GERALD " 'key Shift_L' "str KO"
I was even able to do a complete name-and-address with all the relevant tabs -- click one button and it tabs through all the fields, entering the name and then street address, etc., all on its own. The only weird keystroke is 'key Return' which brings up the finger keyboard and does not enter a return.

So, Benson, thanks!


(Now iif fiferboy will just give us a multi-headed Personal Menu -- a MIRV among launchers -- with the capability to password-protect one of its icon-sets, he'll also have the most convenient maemo password manager, filling in the username then tabbing then entering the password all from one click. :) )


All times are GMT. The time now is 20:06.

vBulletin® Version 3.8.8