
現在のプログラムにテキスト文字列を送信するショートカット キーを構成するにはどうすればよいでしょうか?
目的は、一般的なエントリ(電子メール アドレス、住所、電話番号、ユーザー名、お気に入りの引用など)をより速く入力することです。
テキストを入力する以上の自動化は必要ありません。
Gentoo Linux (3.2.12-gentoo) Xfce デスクトップ環境 (バージョン 4.8)
答え1
一つのシンプルなアプローチはxdotool
、 のように
xdotool type 'text'
答え2
xdotool は動作します。ただし、キーボード ショートカットと統合すると、単純な xdotool タイプ 'text' は失敗します。
次のシェルスクリプトが役に立ちました
windowid=$(xdotool getwindowfocus)
sleep 0.5 && xdotool windowactivate --sync $windowid type 'text'
答え3
答え4
これを使用して、Linux でファイルを開くダイアログの入力を制御できます。
import pyautogui
import subprocess , time
pyautogui.hotkey('ctrl', 'o' , interval = 0.15)
pyautogui.hotkey('ctrl', 'l' , interval = 0.15)
subprocess.Popen("xdotool sleep 0.3 type '{Path_file}'".format(Path_file = "............................") , shell = True)
time.sleep(10)
pyautogui.press('enter')