You are not logged in.

#1 2008-09-10 22:54:19

scooterpd
Member
Registered: 2008-09-01
Posts: 29

New programmer looking for advice (hotstrings)

Hi, i am planning on creating a program/script that will allow me to utilize "hotstrings" (a function utilized in the Windows-only program, AutoHotKey). http://www.autohotkey.com/docs/Hotstrings.htm
Basically, it allows you set a defined abbreviation, and as you type that abbreviation anywhere in windows, you can press a designated "trigger" key that will automagically expand it into the desired result.  For example, if i type "fn" and press the tab key, "fn" becomes "Scott". 

I am looking to either find or write a program/script that will allow me to do this.  I want to be able to define the abbreviations easily, as well as have the option to assign a trigger key of my choosing. 

What is the best language to write this program/script in (i am looking for a speedy and lightweight on resources language)?

BTW, i have looked briefly at Snippits (http://ben.kudria.net/code/snippits), but i am not sure how to install it for arch, plus i want to find out what others feel is the best language for this type of program.
I am new to programming, having only taken a single CS class in college (C++).  I would really like to get into programming, and i think this would be a great start.  AutoHotKey is the one utility on Windows that i really want on Linux.

Offline

#2 2008-09-11 01:19:15

freakcode
Member
From: São Paulo - Brazil
Registered: 2007-11-03
Posts: 410
Website

Re: New programmer looking for advice (hotstrings)

Your problem is not even a language issue, because it could be done in anything... the issue is a infrastructure one: what solution are you going to use to enable this functionality. Is it possible to integrate with a given application? For all applications? Will it be a daemon running and listening to X events? How do you overcome GTK+ or Qt behaviour and stealing of X events? Etc...

If you want to integrate this functionality with a specific application, then you have to look if it's scriptable or accept plugins, and in what languages. If you want this functionality with everything, you will have to mess with X API, so go for languages that have X library bindings.

Offline

#3 2008-09-11 03:18:45

scooterpd
Member
Registered: 2008-09-01
Posts: 29

Re: New programmer looking for advice (hotstrings)

freakcode wrote:

Is it possible to integrate with a given application? For all applications? Will it be a daemon running and listening to X events? How do you overcome GTK+ or Qt behaviour and stealing of X events? Etc...
If you want this functionality with everything, you will have to mess with X API, so go for languages that have X library bindings.

Thank you very much freakcode.
I want it to be functional within every aspect of X, for all applications.  Possibly a deamon listening to all X events.  I am not sure how it would go about stealing X events though. 
I will have to take a look at some of these X library binding languages then.  Can you suggest a starting point?

Offline

#4 2008-09-11 04:51:12

emphire
Member
From: Canada
Registered: 2007-03-21
Posts: 203

Re: New programmer looking for advice (hotstrings)

You might want to have a look at Gizmod (in AUR).  It handles input from input devices and monitors active and forground applications and lets you write little python snippets to handle events from input devices.

Offline

#5 2008-09-11 04:53:03

dav7
Member
From: Australia
Registered: 2008-02-08
Posts: 674

Re: New programmer looking for advice (hotstrings)

Trapping stuff from X is cool and all, but what about if X isn't running? No key-capturing. FYI, you *can* trap keypresses from everything... ie, in or out of X, in a console, while logging in, etc. You just bind to port 0x60.

Take a look at LKL (Linux KeyLogger) to see how it works - it traps port 0x60 in usermode (doesn't require root access or a kernel module - wow). Just be aware that LKL uses a keymap file to figure out what keys were pressed, as it has raw access to the keyboard itself. To get an idea of how the raw keyboard "looks", poke around in /dev/input/by-path/ until you find something that looks like a keyboard (or, inversely, doesn't look like a mouse or anything similar). Then, as root, cat it. On my system, I need to cat "platform-i8042-serio-0-event-kbd". Try hitting random keys, and even stuff like shift. If you have extra keys, try pressing those (but not the power, sleep or standby buttons, or the like!)... oh, the fun. Mind the beeps - "modprobe -r pcspkr" (as root, of course) will make your PC forget how to stop beeping, and "modprobe pcspkr" will help it remember again tongue. CTRL+C *should* get you out of the interesting mess that is raw keyboard input, or failing that, closing the terminal window (which will of course kill bash, su, and your root session).

I don't know if eating port 0x60 will prevent X from working; if this is the case, you might need to implement X support (and detection, so your app can figure out which of hardware or X "key watching" code it needs to run) in addition to hardware trapping, or just implement X trapping by itself, and forget about trapping port 0x60.

In any case, you'll want to take a peek at some sourcecode to see how it's all done... for X key detection, I personally recommend openbox or if you want something a little less... code-full (:P), try poking around Audacious' Global Hotkey plugin, which I can personally confirm works extremely well. As a quick poke, I just checked if one could make it capture "interesting" keys like Scroll Lock, a key that doesn't otherwise seem to react to or do anything, and it worked.

-dav7

Last edited by dav7 (2008-09-11 04:57:51)


Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.

Offline

#6 2008-09-11 06:27:07

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: New programmer looking for advice (hotstrings)

snippits install from ruby gems.... could never quite get it to work correctly in Arch

atm I use text complete extension [firefox and thunderbird] which works fine

very interested in seeing this work


Mr Green

Offline

#7 2008-09-11 08:40:10

scooterpd
Member
Registered: 2008-09-01
Posts: 29

Re: New programmer looking for advice (hotstrings)

@ emphire and dav7:  thank you for the suggestions.  I will check out both Gizmodo and LKL for detecing the input of the keys.  I would still need to figure out the best way to send keystrokes to the cursor of whatever X application is in focus.
@ Mr Green:  Textcomplete looks interesting, maybe i can get some insight from that.  Thanks.  i will check it out.

Offline

#8 2008-09-11 12:53:07

emphire
Member
From: Canada
Registered: 2007-03-21
Posts: 203

Re: New programmer looking for advice (hotstrings)

scooterpd wrote:

I would still need to figure out the best way to send keystrokes to the cursor of whatever X application is in focus.

No problem.  Actually, Gizmod will let you send keystrokes to the application that's in focus.

You should have a look at gnome-do too.

Last edited by emphire (2008-09-11 13:15:06)

Offline

#9 2008-09-14 08:31:45

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: New programmer looking for advice (hotstrings)

I have tested out texer in windows [built on autohotkey!] wondered if its possible in Linux?

Gnome-do is massive as it needs mono, launchy is much lighter

If I/we could figure out cut and paste from clipboard then we could build a text expansion app

ie

type 'em' then hit a hotkey it expands to email@archlinux.org [for example!]

Would be glad to help out where I can

MrG


Mr Green

Offline

#10 2008-09-15 02:57:52

scooterpd
Member
Registered: 2008-09-01
Posts: 29

Re: New programmer looking for advice (hotstrings)

Mr Green wrote:

If I/we could figure out cut and paste from clipboard then we could build a text expansion app
ie type 'em' then hit a hotkey it expands to email@archlinux.org [for example!]
Would be glad to help out where I canMrG

That is exactly what i want to create, and i am looking into it.  I have been a little busy lately so i havent had the time to work on this, but i am down with collaborating with you Mr Green.  Have you written any preliminary code or anything?  I will keep you updated on my progress.

Offline

Board footer

Powered by FluxBB