xdotoolがキーボード入力を混乱させる

xdotoolがキーボード入力を混乱させる

Linuxでマクロを記録して再生できるxevとxdotoolを使用していくつかのスクリプトを作成しようとしています。 xevを使って録音しましたが、再生はほとんど機能しますが、Xセッションが奇妙な状態にあるようです。次のマクロファイルがあります。

keydown e
keyup e
keydown c
keydown h
keyup c
keydown o
keyup h
keyup o
keydown space
keyup space
keydown apostrophe
keyup apostrophe
keydown h
keydown i
keyup h
keyup i
keydown apostrophe
keyup apostrophe

これをと結合しようとしていますcat macro.txt | xargs xdotool。これは端末にテキストを入力しますが、一度完了すると、ほとんどのキーストロークは制御文字を印刷しなくなり、何もしません。リセットするには、コンピュータを数回再起動する必要がありました。これを避ける方法や何が起こっているのか知っていますか?それとも良いLinuxマクロツールは何ですか?

ベストアンサー1

Linux Mintのキーボードショートカットを使用して独自のカスタムマクロを作成し、カスタムショートカットを追加しました。私は--clearmodifiers次のように使用して動作させました。

xdotool key --clearmodifiers Up

役立つことを確認してください。

また、マニュアルには次のように記載されています。

CLEARMODIFIERS --clearmodifiersフラグを持つすべてのコマンドは、コマンド中にアクティブな入力修飾子を消去して後で復元しようとします。

   For example, if you were to run this command:
    xdotool key a

   The result would be 'a' or 'A' depending on whether or not you were holding the shift key on your keyboard. Often it is undesirable to have any modifiers active, so you can tell xdotool to clear any active modifiers.

   The order of operations if you hold shift while running 'xdotool key --clearmodifiers a' is this:

   1. Query for all active modifiers (finds shift, in this case)
   2. Try to clear shift by sending 'key up' for the shift key
   3. Runs normal 'xdotool key a'
   4. Restore shift key by sending 'key down' for shift

   The --clearmodifiers flag can currently clear of the following:

   ·   any key in your active keymap that has a modifier associated with it.  (See xmodmap(1)'s 'xmodmap -pm' output)

   ·   mouse buttons (1, 2, 3, 4, and 5)

   ·   caps lock

おすすめ記事