Repository: autokey/autokey

Issue #117: keyboard.press_key / keyboard.release_key not working?
Created: 2018-01-06T00:37:37Z
Classification:
Bug
Reproducibility:
Always
Summary
I can't get keyboard.press_key / keyboard.release_key to work.
Steps to Reproduce
Script:
keyboard.press_key("<ctrl>")
keyboard.send_key("<home>")
keyboard.release_key("<ctrl>")
Keybinding: ctrl+KeyPad[7]
Expected Results
remap ctrl+7 to ctrl+home
Actual Results
simple "home" key, at least keyboard.press_key("<ctrl>") is ignored
2018-01-06 01:28:19,971 DEBUG - iomediator - <ctrl> pressed
2018-01-06 01:28:21,376 DEBUG - service - Raw key: '<np_home>', modifiers: ['<ctrl>'], Key: 7
2018-01-06 01:28:21,376 DEBUG - service - Window visible title: b'~/.themes/sylpheed-dark \xe2\x80\xa2 (FuzzyFileNav) - Sublime Text (UNREGISTERED)', Window class: 'sublime_text.Sublime_text'
2018-01-06 01:28:21,376 DEBUG - interface - using official python-xlib
2018-01-06 01:28:21,376 INFO - service - Matched hotkey phrase/script with prompt=False
2018-01-06 01:28:21,376 DEBUG - service - Script runner executing: Script('home')
2018-01-06 01:28:21,377 DEBUG - service - Ignored locking error in handle_keypress
2018-01-06 01:28:21,378 DEBUG - interface - Send special key: ['<home>']
2018-01-06 01:28:21,385 DEBUG - interface - Recorded keymap change event
2018-01-06 01:28:21,392 DEBUG - iomediator - <ctrl> pressed
2018-01-06 01:28:21,392 DEBUG - iomediator - <ctrl> released
2018-01-06 01:28:21,586 DEBUG - interface - Ungrabbing hotkey: ['<alt>', '<ctrl>', '<shift>'] 'k'
2018-01-06 01:28:21,587 DEBUG - interface - Ungrabbing hotkey: ['<super>'] '<f12>'
2018-01-06 01:28:21,587 DEBUG - interface - Ignored keymap change event
2018-01-06 01:28:21,613 DEBUG - interface - Ungrabbing hotkey: ['<ctrl>'] '<f7>'

Version
0.94
Distro: Manjaro

Duplicate issue #271: trying to emulate shift+end with autokey
Created: 2019-04-13T06:38:36Z
Classification:
Question
Reproducibility:
Always
Version
AutoKey version: autokey-gtk 0.95.1
Used GUI (Gtk, Qt, or both): gtk
If the problem is known to be present in more than one version, please list all of those.
Installed via: (PPA, pip3, …).
sudo apt-get install autokey-gtk
Linux Distribution: ubuntu 18.04.2 (gnome shell)
Summary
Summary of the problem.
Steps to Reproduce (if applicable)
I try with the following scripts (more info at this stack overflow question)
keyboard.send_key('<shift>+<end>')
---
keyboard.send_key('<shift+end>')
keyboard.send_key('shift+end')
etc...
---
keyboard.press_key('<shift>')
keyboard.send_key('<end>')
keyboard.release_key('<shift>')

I can't emulate the shift-end key combination
Expected Results
To send the ctrl-end

This should happen.

Actual Results

Instead, this happens. it does nothing, or with the last try it only works when you press the key combination the sevons time (???)

Closing comment (2019-04-13T12:48:56Z): That API function may be a bit misleading.
It can only send key presses for a single key, thus it can’t send any kind of keyboard combination.
As a side note, this applies to upper case letters, too. Those are created by keyboard combinations (for example A is created by <shift>+a). This means that keyboard.send_key("A") will send a lower case a.
If you want to send any kind of key combinations, always use keyboard.send_keys().
You only want to use send_key, if you want to use it’s repeat parameter, which allows you to repeat that key any number of times. Send for example 1000 spaces using keyboard.send_key(" ", 1000)
The failure in your last try may actually be a bug. I think the press_key and release_key are executed synchronously, while send_key is executed asynchronously using an event queue. That causes both press_key and release_key to be executed first, screwing up the ordering in your script. That was reported in #117.