Using KeyBD_Event - NotSupportedException

  • Thread starter Christopher Pragash
  • Start date
C

Christopher Pragash

Hello All,

I'm trying to trigger an "Alpha" key press and am attempting to use the
Keybd_Event.

Here is P/Invoke Decleration

<DllImport("Coredll.dll", EntryPoint:="Keybd_Event", SetLastError:=True)> _
Private Shared Sub Keybd_Event(ByVal bVk As Byte, ByVal bScan As Byte, ByVal
dwFlags As Long, ByVal dwExtraInfo As Long)

End Sub

My calling signation is as follows

Call Keybd_Event(VK_ALPHA, 0, 0, 0)

Call Keybd_Event(VK_ALPHA, 0, KEYEVENTF_KEYUP, 0)

I keep getting a "NotSupportedException" when I try to call Keybd_Event. Any
thoughts or suggestions would be really helpful.



Thanks,

Chris
 
D

Daniel Moth

Like your previous question, the problem is with the dllimport declaration.
Last two parameters are not longs... try Int32

Cheers
Daniel
 
P

Paul G. Tobey [eMVP]

And what's a VK_ALPHA?

Paul T.

Daniel Moth said:
Like your previous question, the problem is with the dllimport
declaration. Last two parameters are not longs... try Int32

Cheers
Daniel
 
A

Alex Feinman [MVP]

I stand by the VB version of that code - it works. Just don't expect the SIP
panel to reflect the shift state correctly
 
P

Paul G. Tobey [eMVP]

I don't understand what you're expecting it to do. The shift state is a
very strange thing and I'm betting that what you're expecting is wrong.
Remember that, when the shift key goes down, it (usually), stays down under
the user hits another key, resulting in the capital letter being generated,
eventually. If you send the down event, then the up event, and then press a
key, you'll get what you'd get if you did that on a real keyboard: the
unshifted key.

If you want to send caps lock, you *can* do that and I've done it and it
works (although I've not done it from CF code).

Paul T.
 
A

Alex Feinman [MVP]

<in fake italian accent> Are you talking to me?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Paul G. Tobey said:
I don't understand what you're expecting it to do. The shift state is a
very strange thing and I'm betting that what you're expecting is wrong.
Remember that, when the shift key goes down, it (usually), stays down under
the user hits another key, resulting in the capital letter being generated,
eventually. If you send the down event, then the up event, and then press
a key, you'll get what you'd get if you did that on a real keyboard: the
unshifted key.

If you want to send caps lock, you *can* do that and I've done it and it
works (although I've not done it from CF code).

Paul T.

Alex Feinman said:
I stand by the VB version of that code - it works. Just don't expect the
SIP panel to reflect the shift state correctly

--
Alex Feinman
---
Visit http://www.opennetcf.org
Christopher Pragash said:
I got rid of the errors and followed the article
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=156&SearchTerms=keybd_event
But still, the call to keybd_event seems to execute without errors - but
does not have the behavior expected. I am trying to simulate a VK_Shift
key
as in the sample. The Shift Key dosent seem to be activated.

Any thoughts or ideas?
Chris

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
wrote in message And what's a VK_ALPHA?

Paul T.

Like your previous question, the problem is with the dllimport
declaration. Last two parameters are not longs... try Int32

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hello All,

I'm trying to trigger an "Alpha" key press and am attempting to use
the
Keybd_Event.

Here is P/Invoke Decleration

<DllImport("Coredll.dll", EntryPoint:="Keybd_Event",
SetLastError:=True)>
_
Private Shared Sub Keybd_Event(ByVal bVk As Byte, ByVal bScan As
Byte,
ByVal
dwFlags As Long, ByVal dwExtraInfo As Long)

End Sub

My calling signation is as follows

Call Keybd_Event(VK_ALPHA, 0, 0, 0)

Call Keybd_Event(VK_ALPHA, 0, KEYEVENTF_KEYUP, 0)

I keep getting a "NotSupportedException" when I try to call
Keybd_Event.
Any
thoughts or suggestions would be really helpful.



Thanks,

Chris
 
D

Daniel Moth

LOL :)

"Well I am the only one here..."

--
http://www.danielmoth.com/Blog/


Alex Feinman said:
<in fake italian accent> Are you talking to me?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Paul G. Tobey said:
I don't understand what you're expecting it to do. The shift state is a
very strange thing and I'm betting that what you're expecting is wrong.
Remember that, when the shift key goes down, it (usually), stays down
under the user hits another key, resulting in the capital letter being
generated, eventually. If you send the down event, then the up event, and
then press a key, you'll get what you'd get if you did that on a real
keyboard: the unshifted key.

If you want to send caps lock, you *can* do that and I've done it and it
works (although I've not done it from CF code).

Paul T.

Alex Feinman said:
I stand by the VB version of that code - it works. Just don't expect the
SIP panel to reflect the shift state correctly

--
Alex Feinman
---
Visit http://www.opennetcf.org
I got rid of the errors and followed the article
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=156&SearchTerms=keybd_event
But still, the call to keybd_event seems to execute without errors -
but
does not have the behavior expected. I am trying to simulate a VK_Shift
key
as in the sample. The Shift Key dosent seem to be activated.

Any thoughts or ideas?
Chris

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
wrote in message And what's a VK_ALPHA?

Paul T.

Like your previous question, the problem is with the dllimport
declaration. Last two parameters are not longs... try Int32

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hello All,

I'm trying to trigger an "Alpha" key press and am attempting to use
the
Keybd_Event.

Here is P/Invoke Decleration

<DllImport("Coredll.dll", EntryPoint:="Keybd_Event",
SetLastError:=True)>
_
Private Shared Sub Keybd_Event(ByVal bVk As Byte, ByVal bScan As
Byte,
ByVal
dwFlags As Long, ByVal dwExtraInfo As Long)

End Sub

My calling signation is as follows

Call Keybd_Event(VK_ALPHA, 0, 0, 0)

Call Keybd_Event(VK_ALPHA, 0, KEYEVENTF_KEYUP, 0)

I keep getting a "NotSupportedException" when I try to call
Keybd_Event.
Any
thoughts or suggestions would be really helpful.



Thanks,

Chris
 
P

Paul G. Tobey [eMVP]

No, I'm asking the original seeker...

:)

Paul T.

Alex Feinman said:
<in fake italian accent> Are you talking to me?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Paul G. Tobey said:
I don't understand what you're expecting it to do. The shift state is a
very strange thing and I'm betting that what you're expecting is wrong.
Remember that, when the shift key goes down, it (usually), stays down
under the user hits another key, resulting in the capital letter being
generated, eventually. If you send the down event, then the up event, and
then press a key, you'll get what you'd get if you did that on a real
keyboard: the unshifted key.

If you want to send caps lock, you *can* do that and I've done it and it
works (although I've not done it from CF code).

Paul T.

Alex Feinman said:
I stand by the VB version of that code - it works. Just don't expect the
SIP panel to reflect the shift state correctly

--
Alex Feinman
---
Visit http://www.opennetcf.org
I got rid of the errors and followed the article
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=156&SearchTerms=keybd_event
But still, the call to keybd_event seems to execute without errors -
but
does not have the behavior expected. I am trying to simulate a VK_Shift
key
as in the sample. The Shift Key dosent seem to be activated.

Any thoughts or ideas?
Chris

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
wrote in message And what's a VK_ALPHA?

Paul T.

Like your previous question, the problem is with the dllimport
declaration. Last two parameters are not longs... try Int32

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hello All,

I'm trying to trigger an "Alpha" key press and am attempting to use
the
Keybd_Event.

Here is P/Invoke Decleration

<DllImport("Coredll.dll", EntryPoint:="Keybd_Event",
SetLastError:=True)>
_
Private Shared Sub Keybd_Event(ByVal bVk As Byte, ByVal bScan As
Byte,
ByVal
dwFlags As Long, ByVal dwExtraInfo As Long)

End Sub

My calling signation is as follows

Call Keybd_Event(VK_ALPHA, 0, 0, 0)

Call Keybd_Event(VK_ALPHA, 0, KEYEVENTF_KEYUP, 0)

I keep getting a "NotSupportedException" when I try to call
Keybd_Event.
Any
thoughts or suggestions would be really helpful.



Thanks,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top