Switching windows by simulating Alt-Tab

958 views
Skip to first unread message

Joshua Harlan Lifton

unread,
Nov 8, 2010, 11:48:57 AM11/8/10
to autoke...@googlegroups.com
Hi,

I'm new to AutoKey and having trouble getting AutoKey to switch windows by emulating Alt-Tab.

I added a script called "window shuffler" to the Sample Scripts folder in the configuration window. The abbreviation is set to 'k' with no hotkey and no window filter. The script is:

keyboard.send_keys("<alt>+<tab>")

Running autokey-gtk --verbose, I see the following pertinent log entries when I press 'k':

DEBUG - service - Raw key: u'k', modifiers: [], Key: u'k'
DEBUG - service - No phrase/script matched hotkey
DEBUG - service - Script runner executing: Script('window shuffler')
DEBUG - interface - Send special key: ['<backspace>']
DEBUG - iomediator - Send via event interface
DEBUG - interface - Send modified key: modifiers: [u'<alt>'] key: <tab>

The windows don't switch as I'd expect. Instead, in the terminal window, I see: ^[ followed by a tab. What am I missing? I'm running AutoKey on Ubuntu 10.04 with Python 2.6.5.

Thanks,
JHL

Michael Tunnell

unread,
Nov 8, 2010, 5:45:52 PM11/8/10
to autoke...@googlegroups.com
wait you are wanting to make a shortcut for a shortcut? That doesn't make any sense sorry but I just dont see the point.

Michael Tunnell
Visuex Technologies
www.Visuex.com
(205) 383-3619
(866) 915-4147

:: Quick Links ::
- http://visuex.com/services
- http://visuex.com/portfolio
- http://visuex.com/about

Chris D

unread,
Nov 8, 2010, 6:39:02 PM11/8/10
to autokey-users
That's a good point, also any halfway decent window manager should let
you modify the shortcut for switching windows (Compiz and Kwin both
definitely do). You'd be far better off doing it that way.

On Nov 9, 9:45 am, Michael Tunnell <Mich...@Visuex.com> wrote:
> wait you are wanting to make a shortcut for a shortcut? That doesn't make
> any sense sorry but I just dont see the point.
>
> Michael Tunnell
> Visuex Technologieswww.Visuex.com
> (205) 383-3619
> (866) 915-4147
>
> :: Quick Links ::
> -http://visuex.com/services
> -http://visuex.com/portfolio
> -http://visuex.com/about

Joshua Harlan Lifton

unread,
Nov 8, 2010, 11:09:12 PM11/8/10
to autoke...@googlegroups.com
Fair points. I'm actually trying to get this functionality working in a program I wrote, Plover, which allows a stenotype machine to replace a normal keyboard. Stenotype machines typically only have 24 keys and require an extra layer of software to translate key strokes into words. Both AutoKey and Plover use the Xlib library for capturing and emulating keyboard input. In fact, I used the AutoKey code as a reference for keyboard control. At this point, I'm mostly just curious why sending keycode 23 (Tab on my keyboard) with modifier 0x08 (Mod1, which is apparently Alt on my keyboard) doesn't act as Alt-Tab normally does. I'm somewhat relieved that I can't get it to work in AutoKey either, but I'd rather have it working than agree that neither program can get it to work. In any case, this is turning into more of a dev discussion than a user discussion, so I'm happy to move it off the list if anyone is interested in continuing the conversation.

Thanks,
JHL

Chris D

unread,
Nov 9, 2010, 6:44:20 PM11/9/10
to autokey-users
You could try the keyboard.fake_keypress() method to see if that
works. It uses the xtest extension to generate the keyboard event
rather than directly issuing an event to the X server.

On Nov 9, 3:09 pm, Joshua Harlan Lifton

Joshua Harlan Lifton

unread,
Nov 11, 2010, 2:09:25 PM11/11/10
to autoke...@googlegroups.com
This is exactly what I ended up doing and it worked reasonably well. There were two catches: the display needs to be synced after sending the fake input and the fake input is detected as legitimate input by the Xlib.ext.record context. The former is easy to fix (Xlib.display.Display.sync). The latter needed a little more work - I modified the record context callbacks to ignore a queue of events and then populated that queue with any events that I passed off to the xtest extension.

Cheers,
JHL
Reply all
Reply to author
Forward
0 new messages