Multiple Hotkeys Per Script

118 views
Skip to first unread message

marky1991

unread,
Mar 27, 2013, 6:50:15 PM3/27/13
to autokey-users
I've used autohotkey in the past to create useful programs that I've
come to rely on quite heavily. Now transitioning to running linux as
my main OS, I'd like to use autokey to replicate my old programs.

Most notably, in autohotkey I created an alarm program that triggers a
python script which is responsible for waking me up every morning. To
implement this, I need to be able to pass the time I want to wake up
at to the python script.

In autohotkey, I implemented it so that you press an F key (F1, F2,
etc.) and some combination of the modifier keys to specify the time.
In my particular case, ctl+alt+Fx = x:00, ctl+shift+Fx=x:15, etc.

For one program, I have several hotkeys. (and they all trigger
different behavior in the script) In autohotkey, this is perfectly
natural. In autokey, however, (as far as I can tell), it's one-hotkey-
per-script. There's no way I can create 72 scripts to implement each
possible 15 minute interval of the day. (I guess I could write a
program to generate the scripts, but that's clearly not an ideal
solution. Plus, I'm not sure I'd be able to specify the hotkeys and
having 72 nearly identical tiny scripts is hideous)

Is there any way around this?

Thanks

marky1991

unread,
Mar 27, 2013, 9:21:05 PM3/27/13
to autokey-users
Okay, I think I managed to get it working properly. The only problem
left is arranging for the file to be opened on startup with access to
the autokey internals. he only thing I can think of is calling
run_script, which I obviously don't have access to. Is there a way to
tell autokey to run a script from the command line?

Also, here is the solution that I came up with. If you could look at
it and verify that it looks alright, I'd appreciate it.

class HotKey(iomediator.Waiter, object):
def __init__(self, key, modifiers, func):
super(HotKey, self).__init__(key, modifiers, None,
float("inf"))
self.func = func
def handle_keypress(self, key, modifiers, idk, *args):
if key == self.rawKey and modifiers == self.modifiers:
threading.Thread(target=self.func).start()

def off_monitor():
system.exec_command("/home/mark/Escritorio/off.sh")
kill_monitor = HotKey(iomediator.Key.F1, [iomediator.Key.CONTROL],
off_monitor)
store.set_value("mon", kill_monitor)
Reply all
Reply to author
Forward
0 new messages