Page 1 of 1

How would I create a script to simulate arrow key clicks

Posted: Tue Aug 14, 2018 5:50 pm
by Untitled_47
(I know I’m probably in the wrong section to ask this question) How would I create a script that could click the right key and left key alternating every 5 minutes?

Re: How would I create a script to simulate arrow key clicks

Posted: Tue Aug 14, 2018 7:24 pm
by MrYsLab
Check out https://github.com/asweigart/pyautogui. This may provide the functionality you are looking for.

Re: How would I create a script to simulate arrow key clicks

Posted: Tue Aug 14, 2018 7:31 pm
by klricks
Untitled_47 wrote:
Tue Aug 14, 2018 5:50 pm
(I know I’m probably in the wrong section to ask this question) How would I create a script that could click the right key and left key alternating every 5 minutes?
You can install the xdotool utility. With that you can simulate any keyboard or mouse move/click. Google for details.

Code: Select all

sudo apt update
sudo apt install xdotool
Easy to use in bash scripts. Not sure how hard to use in Python?

Re: How would I create a script to simulate arrow key clicks

Posted: Wed Aug 15, 2018 4:18 pm
by robbes
Consider the keyboard package, available at PyPI. You have to be root to use it.
I think the command would just be
keyboard.press_and_release('right')
See https://pypi.org/project/keyboard/