0

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?

  • I think I'll have to use xdotool – Terry Wendt Apr 17 at 7:00
  • 1
    expect cannot control GUI applications. – glenn jackman Apr 17 at 17:48
  • Thanks glenn, but xdotool has worked out well for me. – Terry Wendt Apr 18 at 23:01
1

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

  • 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. – Terry Wendt Apr 17 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.