Using DirectInput
-
Hey all, I am attempting to create a program that runs in the background, takes keypresses from the keyboard, changes the keypresses to different keys, and sends the new key to the program running in the foreground (for example: I press "A" and the program in the foreground gets "F"). I thought that DirectInput would be the best way to go about this. However, I cannot seem to initialize the program correctly. I want to use the below code to gain control of the keyboard:
Dim keyboard = New Microsoft.DirectX.DirectInput.Device() keyboard.Acquire()
However, "Microsoft.DirectX.DirectInput.Device" wants the guid of the keyboard passed to it as an argument, and I cannot find out how to get this. So, How can I find the guid of the keyboard? I have looked all over the internet for the way to do this, but all I can find is information about directx8 or code in C++. Also, while I am asking, will this program prevent the actual keypresses from getting to the program in the foreground? Using the example from above, if this program can't hide the actual keypresses, then the program in the foreground would get "AF", instead of just "F". Thanks for taking the time to help me. NOTE: I am using Visual Basic 2005 Express Edition. -
Hey all, I am attempting to create a program that runs in the background, takes keypresses from the keyboard, changes the keypresses to different keys, and sends the new key to the program running in the foreground (for example: I press "A" and the program in the foreground gets "F"). I thought that DirectInput would be the best way to go about this. However, I cannot seem to initialize the program correctly. I want to use the below code to gain control of the keyboard:
Dim keyboard = New Microsoft.DirectX.DirectInput.Device() keyboard.Acquire()
However, "Microsoft.DirectX.DirectInput.Device" wants the guid of the keyboard passed to it as an argument, and I cannot find out how to get this. So, How can I find the guid of the keyboard? I have looked all over the internet for the way to do this, but all I can find is information about directx8 or code in C++. Also, while I am asking, will this program prevent the actual keypresses from getting to the program in the foreground? Using the example from above, if this program can't hide the actual keypresses, then the program in the foreground would get "AF", instead of just "F". Thanks for taking the time to help me. NOTE: I am using Visual Basic 2005 Express Edition.http://geekswithblogs.net/clingermangw/articles/84666.aspx[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Hey all, I am attempting to create a program that runs in the background, takes keypresses from the keyboard, changes the keypresses to different keys, and sends the new key to the program running in the foreground (for example: I press "A" and the program in the foreground gets "F"). I thought that DirectInput would be the best way to go about this. However, I cannot seem to initialize the program correctly. I want to use the below code to gain control of the keyboard:
Dim keyboard = New Microsoft.DirectX.DirectInput.Device() keyboard.Acquire()
However, "Microsoft.DirectX.DirectInput.Device" wants the guid of the keyboard passed to it as an argument, and I cannot find out how to get this. So, How can I find the guid of the keyboard? I have looked all over the internet for the way to do this, but all I can find is information about directx8 or code in C++. Also, while I am asking, will this program prevent the actual keypresses from getting to the program in the foreground? Using the example from above, if this program can't hide the actual keypresses, then the program in the foreground would get "AF", instead of just "F". Thanks for taking the time to help me. NOTE: I am using Visual Basic 2005 Express Edition.You don't need DirectX or DirectInput for this. Just write a Global Keyboard Hook. Search the articles for "keybook hook", or Google for "VB.NET Global Keyboard Hook" and you'll find lots of resources.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Hey all, I am attempting to create a program that runs in the background, takes keypresses from the keyboard, changes the keypresses to different keys, and sends the new key to the program running in the foreground (for example: I press "A" and the program in the foreground gets "F"). I thought that DirectInput would be the best way to go about this. However, I cannot seem to initialize the program correctly. I want to use the below code to gain control of the keyboard:
Dim keyboard = New Microsoft.DirectX.DirectInput.Device() keyboard.Acquire()
However, "Microsoft.DirectX.DirectInput.Device" wants the guid of the keyboard passed to it as an argument, and I cannot find out how to get this. So, How can I find the guid of the keyboard? I have looked all over the internet for the way to do this, but all I can find is information about directx8 or code in C++. Also, while I am asking, will this program prevent the actual keypresses from getting to the program in the foreground? Using the example from above, if this program can't hide the actual keypresses, then the program in the foreground would get "AF", instead of just "F". Thanks for taking the time to help me. NOTE: I am using Visual Basic 2005 Express Edition.You can find the keyboard's guid on here:
Microsoft.DirectX.DirectInput.SystemGuid.Keyboard
In other words, you should create your dxkeyboard object like the following example:
Protected mKeyboard As Microsoft.DirectX.DirectInput.Device = Nothing mKeyboard = New Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard)
Sincerilly yours. Manusoftar®