Question

I am computer science student and I am working, with an electronic engineer on gloves that recognize some hand's motions (Vertical, horizontal ones).

To present the project, we thought about making a little application to control power point slides. The concept is very simple: when we move one hand to the left, the slides passes to the next one, and when we move it to the right, it goes back to the previous one.

To do that, I thought about simulating the keyboard right and left arrows (that's what we use basically to change slides).

The question is: is it possible to that? Or do you think there is a better idea?

Thank you very much for reading

Was it helpful?

Solution

I just found this script that does EXACTLY what I wanted.

It is based on a Linux command line that generates fake inputs xte (use sudo apt-get install xte in debian based distribution to download it.

I'm using a system call in python to do the job.

In this example, we are generating two right arrow strikes each two seconds. We can test it by positioning the cursor in a text document, launch the script, and watch the cursor move.

from subprocess import Popen, PIPE
import time


def keypress(sequence):
    p = Popen(['xte'], stdin=PIPE)
    p.communicate(input=sequence)

time.sleep(2)
keypress("key Right ")
time.sleep(2)
keypress("key Right ")
time.sleep(2)
keypress("key Right ")
time.sleep(2)
keypress("key Right ")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top