SL5net
SL5net

Reputation: 2556

AutoKey: Switch to last active application like Alt-Tab by using AutoKey

is it possible to send the alt+tab for switch to last window with AutoKey ?

i tried without success:

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

Or forward window:

keyboard.press_key('<alt>')
keyboard.press_key('<tab>')
keyboard.release_key('<tab>')
keyboard.release_key('<alt>')

Or backward window:

keyboard.press_key('<alt>')
keyboard.press_key('<shift>')
keyboard.press_key('<tab>')
keyboard.release_key('<tab>')
keyboard.release_key('<shift>')
keyboard.release_key('<alt>')

result: no error but only moves the tab count inside the editor.

Upvotes: 1

Views: 581

Answers (3)

Jaggz
Jaggz

Reputation: 21

https://autokey.github.io/api/window.html#autokey.scripting.Window.activate

activate(title, switchDesktop=False, matchClass=False)
    Activate the specified window, giving it input focus

See more at that page.

Upvotes: 0

James Endres Howell
James Endres Howell

Reputation: 11

Autokey's Window class allows you to activate a window by name (via wmctrl), among other functionality. Something in that class may be what you're looking for.

Upvotes: 1

Joe
Joe

Reputation: 371

TL;DR: Not directly with our API.

The AutoKey API talks directly to the current active window. So, sending events targeted at the desktop (DTE) will only work if the current active window recognizes them as such and either forwards them to the DTE or emulates what they do.

However, since AutoKey scripts are written in full Python 3, if you can figure out how to do it yourself in Python, AutoKey can run it for you. And, if some other solution is available, you can run it from within an AutoKey script using the subprocess module.

Upvotes: 2

Related Questions