Hello,

Thanks for your hard work.
I don't know why but every ten years I try to automate something with
virtual input du moment and the packages are always broken...
"Mere mortals should not be able to have huge powers" ? ;)
Seriously, I was fed up of typing on my keyboard :
Ctrl+S Alt+` Tab Tab Enter
just to save a webpage in Firefox.
Hence, I naively thought "I may automate this key sequence".
I first found ydotool and ydotoold
but installing the service for that is a mess.
It does not work out of the box... Why ?
Then I found python lib uinput.
Nice there is a package for that on my version of Ubuntu 23.04 :)
It also does not work out of the box... Why ?
I did all the manual stuff required :
- add uinput in /etc/modules
- create group uinput
- add my user to this group
- create rule in udev
Can someone provide a working script, please ?

Here is my script "FirefoxSave.py" :
------------------------------------------
import uinput

with uinput.Device(
    [
        uinput.KEY_LEFTCTRL,
        uinput.KEY_S,
        uinput.KEY_LEFTALT,
        uinput.KEY_GRAVE,
        uinput.KEY_TAB,
        uinput.KEY_ENTER,
        uinput.KEY_LEFTMETA,
        uinput.KEY_RIGHTMETA,
    ]
) as device:
    # This combo should launch the calculator that is in my dash
    # This was for a simpler test.
    device.emit_combo(
        [
            uinput.KEY_RIGHTMETA,
            uinput.KEY_0,
        ]
    )
    # This is the real key sequence.
    device.emit_combo(
        [
            uinput.KEY_LEFTCTRL,
            uinput.KEY_S,
        ]
    )
    device.emit_combo(
        [
           uinput.KEY_LEFTALT,
           uinput.KEY_GRAVE,
        ]
    )
    device.emit_click(uinput.KEY_TAB)
    device.emit_click(uinput.KEY_TAB)
    device.emit_click(uinput.KEY_ENTER)

Thanks in advance if I do get a response one day XD, best regards,
    Laurent Lyaudet

-- 
Ubuntu-motu mailing list
Ubuntu-motu@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-motu

Reply via email to