Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Snippet to inject text using Python. See:
- # https://pynput.readthedocs.io/en/latest/keyboard.html#controlling-the-keyboard
- - trigger: :test
- replace: "{{output}}" # Redundant placeholder
- vars:
- - name: output
- type: script
- params:
- args:
- - python
- - -c
- - |
- import time
- from pynput.keyboard import Controller, Key
- keyboard = Controller()
- trigger = ":test" # Match the trigger string length
- # Helper function to press a key multiple times.
- def press_key(key, times=1): [keyboard.tap(key) for _ in range(times)]
- # Remove trigger characters using the function
- press_key(Key.backspace, times=len(trigger))
- # Type a message followed by a newline
- keyboard.type("Replace this with text and variables")
- keyboard.tap(Key.enter)
- time.sleep(1.5) # Wait for 1.5 seconds
- # Press the Tab key twice and then press the Space key
- press_key(Key.tab, times=2)
- keyboard.tap(Key.space)
- # Type some more text
- keyboard.type("Some more text here")
- # Supply dummy characters for Espanso to remove
- keyboard.type(trigger)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement