Last active
January 5, 2018 12:58
-
-
Save yhstvhd/48ccbc52bc703392bcc0e468f11f015a to your computer and use it in GitHub Desktop.
バックグラウンド(じゃないけど)でキー入力を検出するこーど(PrintSCreen)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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