linux - How to run shortkeys using Python? -
i understand, can execute linux shell commands using subprocess
import subprocess subprocess.call(["ls", "-l"])
what if want run ctrl+c action on terminal?
my use case is:
1> open linux screen 2> run command on first window 3> create window in same screen 4> run command on second window
it pretty obvious want automate part of daily routine.
aah! found solution you;
if use ubuntu or backtrack (a debian based linux flavour) can install this: apt-get install xautomation
and invoking keystrokes little easier, people coding in english, more complicated:
from subprocess import popen, pipe control_f4_sequence = '''keydown control_l key f4 keyup control_l ''' shift_a_sequence = '''keydown shift_l key keyup shift_l ''' def keypress(sequence): p = popen(['xte'], stdin=pipe) p.communicate(input=sequence) keypress(shift_a_sequence) keypress(control_f4_sequence)
Comments
Post a Comment