Holding down keys II

  • Thread starter Thread starter Daniel N
  • Start date Start date
D

Daniel N

In my never ending search I found code that might help me to simulate
holding down keys:



http://www.developerfusion.co.uk/show/68/2/



However, when I copy and paste, I get the errors;



KeyCodeConstants is not defined



and



vbKeyShift is not declared



Would I put the HEX equivalents? I am new to vb.net and unsure of what to
do.
 
Daniel,

I am sure that you got at least 2 solutions to your problem in this
newsgroup. Why are you than trying to get help for a solution which comes
from another board?

Cor
 
Daniel N said:
In my never ending search I found code that might help me to simulate
holding down keys:



http://www.developerfusion.co.uk/show/68/2/



However, when I copy and paste, I get the errors;



KeyCodeConstants is not defined

First, the declarations in the article above are written for VB6. The key
codes can be extracted from the according header file (check out the MSDN
documentation on 'keybd_event' to determine the header file.

\\
Private Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Int32, _
ByVal dwExtraInfo As Int32 _
)

Private Const KEYEVENTF_KEYUP As Int32= &H2


Private Const VK_LWIN As Byte = &H5B
Private Const VK_APPS As Byte = &H5D
Private Const VK_CONTROL As Byte = &H11
Private Const VK_ESCAPE As Byte = &H1B

Public Sub PopUp()
keybd_event(VK_LWIN, 0, 0, 0)
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub

Public Sub PopUpCtrlEsc()
keybd_event(VK_CONTROL, 0, 0, 0)
keybd_event(VK_ESCAPE, 0, 0, 0)
keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
End Sub
///
 
Herfried,

Does that mean that your previous answer was wrong?

Maybe it is wise to set that in that message for others who are searching on
that?

Cor
 
Back
Top