How can I use in wpf 2 keyboard that connected to my computer(its part of a project) ?
For example, if I use "w", it will activate a button but on the second keyboard it won't activate it.
Use the Windows Raw Input API . It provides a way for applications to accept raw input from any HID, including keyboard and mouse.
You can use the Windows Raw Input API . Normally, windows intercepts keyboard input for you and makes it easier to deal with. Using the raw input API, you can deal directly with each keyboard instead of having windows treat both keyboards like a single keyboard. The downside is that the interaction will be much more low level. How you approach depends on your use case, but here are the main methods you probably care about in User32.dll:
You can import these methods to call them from C# for example like this:
[DllImport("User32.dll")]
extern static uint GetRawInputDeviceList(IntPtr pRawInputDeviceList, ref uint uiNumDevices, uint cbSize);
EDIT: I haven't tried it before, but this library looks like it could give you a nice API for this kind of work. https://github.com/aelij/RawInputProcessor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.