2

I'm writing a script that will open up tmux in my terminal and split the windows. To do that I need to send tmux, Ctrl + b and % to the terminal.

def make_win():
    subprocess.call('tmux', shell=True)
    subprocess.call('Ctrl', 'b', shell=True)
    subprocess.call('%', shell=True)

The 'Ctrl' and 'b' keys need to be held down/clicked at the same time.

Eric MacLeod
  • 451
  • 3
  • 7
  • 18

1 Answers1

2

Unfortunately, subprocess per se has no capabilities to send key pressed events (to the sub-process or to any other process). You will need to adopt a different | approach.

Community
  • 1
  • 1
Idos
  • 15,053
  • 14
  • 60
  • 75