Technically Impossible

Lets look at the weak link in your statement. Anything "Technically Impossible" basically means we haven't figured out how yet.

20211205

https://espio999.tumblr.com/post/101311177953/%E4%BA%BA%E3%80%85%E3%81%8B%E3%82%89%E6%84%9B%E3%81%95%E3%82%8C%E3%82%8B%E3%81%8B%E5%BF%85%E8%A6%81%E3%81%A8%E3%81%95%E3%82%8C%E3%82%8B%E3%81%8B%E3%81%93%E3%81%AE%E3%81%A9%E3%81%A1%E3%82%89%E3%81%8B%E3%81%AE%E5%9F%BA%E6%BA%96%E3%82%92%E6%BA%80%E3%81%9F%E3%81%95%E3%81%AA%E3%81%84%E9%99%90%E3%82%8A%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9%E3%81%AF%E7%B9%81%E6%A0%84%E3%81%97%E3%81%AA%E3%81%84
espio999.tumblr.com

キー押下イベント

発生順序 操作
1 KeyDown キーが押し下げられた
2 KeyPress KeyDownの後
キーが押されている
キャラクター・キー
スペース
バックスペース
3 KeyUp キーが押し上げられた

The KeyPress event is not raised by non-character keys other than space and backspace; however, the non-character keys do raise the KeyDown and KeyUp events.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.keypress?view=netframework-4.8:text

押されたキーを判別する場合、KeyUpで処理するのが良さそうだ。

private void Form1_KeyUp(object sender, KeyEventArgs e)
{
    label1.Text = $"KeyUp code: {e.KeyCode}, value: {e.KeyValue}, modifiers: {e.Modifiers}";
}

Active Windowのスクリーンショットを撮る方法

github.com

次の特性を持つフォームを生成する。

  • 最前面
  • 全画面
  • 透明

フォーム上で、マウスで指定した長方形領域をキャプチャする。

Active Windowを指定してキャプチャするには不向き。キャプチャ処理が実行されるフォームが常に最前面に存在するため、キャプチャしたいWindowがActive Windowになることがないため。

タスクトレイ常駐のアプリケーションからキャプチャするしかないか?
www.fenet.jp
www.hiramine.com