This is not a question as such, more a solution. I have been trying to code a routine which will allow me to press a key on my Joystick (which sends a DX button) and simulates pressing and holding a key in the down position at the same time. Basically, it boiled down to three lines of code:
10. Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
20. If (condition=true) then
30. keybd_event(Keys.Scroll, 0, 0, 0)
40. Else
50. keybd_event(Keys.Scroll, 0, 2, 0)
60. EndIf
Line numbers added for clarity. As you can see, line 20 holds down the SCROLL LOCK key, line 30 releases it again. Although the code works perfectly for my needs (in a 1 hour 35 minute session I experienced no problems in Falcon BMS 4.33U2, IVC Client, and FRAPS), to get this to work, I had to disable the MDA using Debug>Exceptions>Managed Debugging Assistants>PInvokeStackImbalance (thrown).
My question is - is this a "safe" way to program, or in other words, have I cheated somewhere to get this to work? If it is not "safe", is there a proper way to do the same thing?