
如何配置快捷鍵以將文字字串傳送到目前程式?
目的是更快地輸入常見條目(電子郵件地址、街道地址、電話號碼、使用者名稱、最喜歡的引言等)。
除了輸入文字之外,我不需要任何進一步的自動化。
Gentoo Linux (3.2.12-gentoo) Xfce 桌面環境(版本 4.8)
答案1
一種簡單的方法是xdotool
, 喜歡
xdotool type 'text'
答案2
xdotool 可以工作。但是,如果將其與鍵盤快捷鍵整合..簡單的 xdotool 類型「文字」將會失敗。
以下 shell 腳本在這方面幫助了我
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')