pythonpython-3.xautokey

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.


Solution

  • 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.