1

I have two windowed applications that I need to send a series of keystrokes to. I need to Alt-Tab back and forth between the apps, and I'd like to be able to reduce the number of keystrokes from six to one.

I start out with the first window active, and type:

Alt-Tab      //makes second window active
Right Arrow  //
Alt-Tab      //makes first window active
F5

Rinse and Repeat.

I know this doesn't sound like much, but I might have to do this a couple thousand times! If I could reduce this task from 12,000 keystrokes down to pressing a single button 2,000 times, I'd be very grateful!

I'm wondering if I find out my application's PIDs, if I can then use expect to send the keystrokes to those PIDs?

4
  • I think I'll have to use xdotool Apr 17, 2019 at 7:00
  • 1
    expect cannot control GUI applications. Apr 17, 2019 at 17:48
  • Thanks glenn, but xdotool has worked out well for me. Apr 18, 2019 at 23:01
  • I would be interested to see your solution as I am doing something similar.
    – stephenmm
    Dec 28, 2020 at 18:52

1 Answer 1

1

I have newer tested it, but https://sourceforge.net/projects/xautomation/ could also be an alternative to xdotool.

1
  • Thanks Espen, I'll check out xautomation. I wrote a short bash script using xdotool that does what I want. It's not the most elegant solution, but after I find out the window IDs of my apps, and plug them into the script, I only need to press two keys for every iteration instead of six. Apr 17, 2019 at 8:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .