trigger script using only modifiers

63 views
Skip to first unread message

Jose Riha

unread,
Dec 14, 2021, 4:15:35 PM12/14/21
to autokey-users
hello all,

i am totally new here and in fact only discovered autokey recently. one thing i would like to use it is for displaying a small OSD information when a hyper key (control+alt+shift+super) is pressed and held. i have many programs tied to this combination (hyper + f for instance starts firefox) and getting a clue would come handy, not just me but also for other members of the family using the computer.

i can already see that autokey intercepts everything i press including the pressed and released modifiers but i was unable to figure out how to make this work since hotkey needs a regular key to be used together with the modifier.

thank you for your feedback,

jose
Message has been deleted

Stephen Meech

unread,
Dec 14, 2021, 6:08:44 PM12/14/21
to autokey-users
As you have discovered, Autokey can't do this.

The Application Shortcuts in Keyboard settings will permit you to assign a command to a combination of modifiers alone. However, I don't know how to detect when the keys are released, in order to close your OSD.

Perhaps use a combination plus <Return>, then <Esc> to close the OSD. This is how I display an image of extended keyboard items using feh when I press <Super>+<Return>.

(Linux Mint XFCE)

Little Girl

unread,
Dec 15, 2021, 8:57:00 AM12/15/21
to autokey-users
Hey there,

As something of a work-around, you could write a script that's triggered by a hotkey or an abbreviation and then waits for specified keypresses to take specified actions.The AutoKey API offers a way to wait for a keypress with the keyboard.wait_for_keypress() method.

This example uses an infinite loop that will only display the specified dialog if the Escape key is pressed:

keyboard.wait_for_keypress("<escape>")
dialog.info_dialog(message="The Escape key was pressed.")

This example uses a ten-second time-out. It will display the specified dialog regardless of whether the Escape key is pressed or not. If the Escape key is pressed within ten seconds, the dialog will be displayed immediately. If not, then the dialog will be displayed after ten seconds:

keyboard.wait_for_keypress("<escape>", timeOut=10.0)
dialog.info_dialog(message="The Escape key was pressed.")


Reply all
Reply to author
Forward
0 new messages