I am using a project hosted at http://inputsimu开发者_运维问答lator.codeplex.com/ It uses default Microsoft keyboard input codes to SendKeys what key is actually pressed.
If I have to use my winform as keyboard to perform keyboard functionality like Microsoft's tool, On-Screen Keyboard, I have to provide focus to the application that needs to be edited.
Let's say for example I have to type a document in Word, so it has focus. But when I click my form buttons, focus transfers to my Form and nothing gets written on Word.
So...
What I want is to make a form control that does not take focus but performs functionally.
The WS_EX_NOACTIVATE window style flag was designed to do this. Here's a sample form that implements it:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.TopMost = true;
}
protected override CreateParams CreateParams {
get {
var cp = base.CreateParams;
cp.ExStyle |= 0x08000000; // Turn on WS_EX_NOACTIVATE;
return cp;
}
}
}
Keyboard Spy: implementation and counter measures
精彩评论