這裏我只獲取KeyCode上的KeyUp事件,我想要獲取關鍵代碼,同時關注窗口的任何應用程序。實際上,我正在綁定關鍵記錄器窗口應用程序,當我失去對錶單的焦點時,我如何獲得關鍵代碼?如何獲得關鍵代碼,同時關注任何窗口應用程序
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
Fun_Val(e);
}
private void Fun_Val(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Space:
cl.Fun_Write(" ");
break;
case Keys.Enter:
cl.Fun_Write(Environment.NewLine);
break;
case Keys.LShiftKey:
cl.Fun_Write(" ");
break;
case Keys.RShiftKey:
cl.Fun_Write(" ");
break;
default:
if (Control.ModifierKeys != Keys.Shift)
{
cl.Fun_Write(e.KeyCode.ToString().ToLower());
}
else
{
cl.Fun_Write(e.KeyCode.ToString());
}
break;
}
}
public void Fun_Write(string word)
{
// filename = DateTime.Now.Month + "-" + DateTime.Now.Day + filename;
path = Path.Combine(dir, filename);
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo fi = new FileInfo(path);
if (!di.Exists)
{
di.Create();
if (!fi.Exists)
{
fi.Create();
}
}
else
{
StreamWriter sw = new StreamWriter(path, true);
sw.Write(word, true);
sw.Close();
}
}
我剛剛downvoted,因爲您確實需要幫助創建惡意代碼(或至少要求我們幫助您獲取它工作)。我沒有發現這樣的問題適合堆棧溢出,但是別人怎麼看這個問題我不知道。 –