2
2

C# SendKeysを使ったTipsまとめ

Posted at

はじめに

キーストロークをアプリケーションに送信するSendKeysのTipsです。

チェックボックス、ラジオボタン

選択にはEnterではなくスペースキーを使う。

SendKeys.Send(" ");

複雑な入力

例) Shiftを押しながらTABキーを押したい場合、+() を組み合わせる。

Shift : +
Ctrl : ^
Alt : %

SendKeys.Send("+({TAB})"); // `Shift`を押しながら`TAB`

a を 10 回押す

{a 10} 

DoEvent

キーストロークをアプリケーションに送信しても受け取ったことを確認できないので
DoEventを使った検証をされています。
タイマーで上手くいかなかった場合はこちらを試してみるのもありかと思いました。

参考ページ

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2