Home All Groups Group Topic Archive Search About
Author
20 Jul 2006 2:56 AM
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.

Author
20 Jul 2006 3:32 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Daniel N" <saintdark_***@yahoo.com> schreef in bericht
news:%iCvg.195$FI7.128@fe10.lga...
> 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.
>
>
Author
20 Jul 2006 10:04 AM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Daniel N" <saintdark_***@yahoo.com> schrieb:
> 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
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
20 Jul 2006 10:15 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:OLf5hP%23qGHA.3380@TK2MSFTNGP04.phx.gbl...
> "Daniel N" <saintdark_***@yahoo.com> schrieb:
>> 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
> ///
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
>