简体   繁体   中英

Using xte in linux script

I have a question about xte and how it works in a linux ubuntu script.

My script opens a program (./program_to_open) and a file concurrently (~path/to/file.txt). The line is:

./program_to_open ~/path/to/file.txt

I would like to use the keyboard command "Control+S" to save this file. If I understand xte correctly, and I probably don't, I'd use a script like this:

#!/bin/bash
cd Desktop/user/folder...
./file_to_open ~/path/to/file.txt
sleep 3
xte 'key Control_S'

...or...

#!/bin/bash
cd Desktop/user/folder...    
./file_to_open ~/path/to/file.txt
sleep 3
xte 'keydown Control_S'
sleep 1
xte 'keyup Control_S'

Is this the way it's supposed to work or am I overlooking something?

It seems that the only way to hold down multiple keys at the same with xte is using several keydown commands. The following worked for me:

xte 'sleep 3' 'keydown Control_L' 'keydown s' 'keyup Control_L' 'keyup s'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM