Skip to content

Instantly share code, notes, and snippets.

@yhstvhd
Last active January 5, 2018 12:58
Show Gist options
  • Save yhstvhd/48ccbc52bc703392bcc0e468f11f015a to your computer and use it in GitHub Desktop.
Save yhstvhd/48ccbc52bc703392bcc0e468f11f015a to your computer and use it in GitHub Desktop.
バックグラウンド(じゃないけど)でキー入力を検出するこーど(PrintSCreen)
using System;
using System.Runtime.InteropServices; //DllImportで使う
class Program
{
[DllImport("user32")]
private static extern int GetAsyncKeyState(int vKey); //非同期でキーを検出
public static void Main()
{
while(true)
{
if(GetAsyncKeyState(44) !=0) //引数44は仮想コードキー(PrintScreen)
{
//Keyが押されたときの処理
}
System.Threading.Thread.Sleep(200);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment