Hi Joe, Jack, Little Girl,
I'm finally reporting back with some Autokey traces. Sorry for the delay, been quite busy.
Let me summarize again my setup and my problem:
Ubuntu 20.04
KDE Plasma 5.18.8, Qt version 5.12.8
Autokey-qt 0.96.0 [also -gtk, see below]
Dvorak keyboard or standard US keyboard, the situation is the same in both.
I set up two scripts:
"UP"
keyboard.send_keys("<up>")
Hotkey: <ctrl>+.
Window Filter: .
"DOWN"
keyboard.send_keys("<down>")
Hotkey: <ctrl>+e
Window Filer: (?!(.*\.Emacs))
* The script "UP" is intended to be a global remapping of ctrl+. to the "up" key.
* The script "DOWN" is intended to be a remapping of ctrl+e to the "down" key in all windows *except* Emacs windows.
* All Emacs windows in my system have window-class "emacs.Emacs" and their window-title always ends with ".Emacs".
Observed behaviour:
* In all non-Emacs windows, also newly opened ones, the two key combinations work as intended.
* In Emacs windows *that already exist when Autokey is started*, the two key combinations work as intended.
* In Emacs windows *opened after Autokey is started*, the UP script work as intended, but the DOWN script (the one with negative matching) does not produce any output, as if no key was pressed.
Here are traces obtained with "autokey-qt -l" and the corresponding actions:
(a) Moving mouse to an existing Emacs window ('scrach'), pressing ctrl+.:
2022-07-12 21:41:59,015 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:41:59,441 DEBUG - autokey.service - Raw key: '.', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: .
2022-07-12 21:41:59,441 DEBUG - autokey.service - Window visible title: '*scratch* .Emacs', Window class: 'emacs.Emacs'
2022-07-12 21:41:59,441 INFO - autokey.service - Matched Script "up" with hotkey and prompt=False
2022-07-12 21:41:59,448 DEBUG - autokey.service - Script runner executing: Script('up')
2022-07-12 21:41:59,449 DEBUG - autokey.iomediator.iomediator - Send via event interface
2022-07-12 21:41:59,451 DEBUG - autokey.interface - Send special key: ['<up>']
2022-07-12 21:41:59,673 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
(b) Moving mouse to an existing Emacs window ('scrach'), pressing ctrl+e:
2022-07-12 21:42:04,050 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:42:04,499 DEBUG - autokey.service - Raw key: 'e', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: e
2022-07-12 21:42:04,500 DEBUG - autokey.service - Window visible title: '*scratch* .Emacs', Window class: 'emacs.Emacs'
2022-07-12 21:42:04,724 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
(c) Moving mouse to a newly opened Emacs window ('Messages'), pressing ctrl+.:
2022-07-12 21:42:50,755 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:42:51,070 DEBUG - autokey.service - Raw key: '.', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: .
2022-07-12 21:42:51,070 DEBUG - autokey.service - Window visible title: '*Messages* .Emacs', Window class: 'emacs.Emacs'
2022-07-12 21:42:51,070 INFO - autokey.service - Matched Script "up" with hotkey and prompt=False
2022-07-12 21:42:51,077 DEBUG - autokey.service - Script runner executing: Script('up')
2022-07-12 21:42:51,077 DEBUG - autokey.iomediator.iomediator - Send via event interface
2022-07-12 21:42:51,079 DEBUG - autokey.interface - Send special key: ['<up>']
2022-07-12 21:42:51,293 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
(d) Moving mouse to a newly opened Emacs window ('Messages'), pressing ctrl+e:
2022-07-12 21:42:54,076 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:42:54,573 DEBUG - autokey.service - Raw key: 'e', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: e
2022-07-12 21:42:54,573 DEBUG - autokey.service - Window visible title: '*Messages* .Emacs', Window class: 'emacs.Emacs'
2022-07-12 21:42:55,060 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
(e) Moving mouse to a non-Emacs window (Dolphin file browser), pressing ctrl+.:
2022-07-12 21:43:26,014 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:43:26,311 DEBUG - autokey.service - Raw key: '.', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: .
2022-07-12 21:43:26,311 DEBUG - autokey.service - Window visible title: '.config — Dolphin', Window class: 'dolphin.dolphin'
2022-07-12 21:43:26,314 INFO - autokey.service - Matched Script "up" with hotkey and prompt=False
2022-07-12 21:43:26,318 DEBUG - autokey.service - Script runner executing: Script('up')
2022-07-12 21:43:26,318 DEBUG - autokey.iomediator.iomediator - Send via event interface
2022-07-12 21:43:26,325 DEBUG - autokey.interface - Send special key: ['<up>']
2022-07-12 21:43:26,513 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
(f) Moving mouse to a non-Emacs window (Dolphin file browser), pressing ctrl+e:
2022-07-12 21:43:28,137 DEBUG - autokey.iomediator.iomediator - Key.CONTROL pressed
2022-07-12 21:43:28,472 DEBUG - autokey.service - Raw key: 'e', modifiers: [<Key.CONTROL: '<ctrl>'>], Key: e
2022-07-12 21:43:28,472 DEBUG - autokey.service - Window visible title: '.config — Dolphin', Window class: 'dolphin.dolphin'
2022-07-12 21:43:28,473 INFO - autokey.service - Matched Script "down" with hotkey and prompt=False
2022-07-12 21:43:28,483 DEBUG - autokey.service - Script runner executing: Script('down')
2022-07-12 21:43:28,484 DEBUG - autokey.iomediator.iomediator - Send via event interface
2022-07-12 21:43:28,491 DEBUG - autokey.interface - Send special key: ['<down>']
2022-07-12 21:43:28,707 DEBUG - autokey.iomediator.iomediator - Key.CONTROL released
I see that the trace in the Emacs cases (b) and (d) is the same, but in case (b) Emacs correctly receives ctrl+e (unmodified keypress sent), while in case (d) Emacs does not receive anything at all (the unmodified ctrl+e was expected instead).
* Let me add: if I redo as above but with the titles of the two Emacs windows swapped, the situation remains the same. So it's the fact that's a new window that seems to be breaking things, not the specific window title.
Also: I changed from Gnome & autokey-gtk 0.96.0 to KDE & autokey-qt 0.96.0, and this quirk happens in both desktops.
Let me know if I can send you any other info. Thank you again for Autokey and your help!
Cheers,
Luca