473,215 Members | 1,244 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,215 software developers and data experts.

Keys.Oem1 etc to real character

Hi,

How can I convert KeyCode's to the real character? For instance: the row of
keys on a keyboard under the F-keys return as Keycode the Keys.Oem1,
Keys.Oem2 etc... Depending on the keyboard layout it is another character
(and also depening on the fact if you have used Shift or Alt Gr).

But my problem is: I would like to knwo the exact character the user sees on
the screen.

I'm using VB.NET 2003.

Thanks a lot in advance,

Pieter
Dec 14 '06 #1
5 1627
Ummmmmmmm ... How about Convert.ToChar(Keys.Oem1)
"Pieter" <pi****************@hotmail.comwrote in message
news:Ol*************@TK2MSFTNGP06.phx.gbl...
Hi,

How can I convert KeyCode's to the real character? For instance: the row
of keys on a keyboard under the F-keys return as Keycode the Keys.Oem1,
Keys.Oem2 etc... Depending on the keyboard layout it is another character
(and also depening on the fact if you have used Shift or Alt Gr).

But my problem is: I would like to knwo the exact character the user sees
on the screen.

I'm using VB.NET 2003.

Thanks a lot in advance,

Pieter

Dec 14 '06 #2
or even Asc(Keys.Oem1)
Dec 14 '06 #3
No. Asc(Keys.Oem1) will return a byte. You need AscW(Keys.Oem1) to return
a char.
"Stuart Nathan" <st***********@homecall.co.ukwrote in message
news:u9**************@TK2MSFTNGP06.phx.gbl...
or even Asc(Keys.Oem1)

Dec 14 '06 #4
Hi,

I tried these alreaddy, but they don't work...
For instance:
The 2 upper left keys on my keyboard (under the Esc-key) are (I'm using an
Belgian Azerty): "" and "&".

What I get for them is:
"":
- KeyCode = 222 = Keys.OemQuotes
- Convert.ToChar(e.KeyCode) = ""c (I don't even knwo the name of this sign,
I hope it shows up in the newsreader...)
- Asc(e.KeyCode) = AscW(e.KeyCode) = 50

"&":
- KeyCode = 49 = Keys.D1
- Convert.ToChar(e.KeyCode) = "1"c (If I do Shift + ThisKey then I get
indeed "1", but I did it without the Shift...)
- Asc(e.KeyCode) = AscW(e.KeyCode) = 52
Anybody has any idea??? I'm really stuck on this :-(


"Stephany Young" <noone@localhostwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
No. Asc(Keys.Oem1) will return a byte. You need AscW(Keys.Oem1) to
return a char.
"Stuart Nathan" <st***********@homecall.co.ukwrote in message
news:u9**************@TK2MSFTNGP06.phx.gbl...
>or even Asc(Keys.Oem1)


Dec 14 '06 #5
Aaah, I found it :-)

Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Integer, ByVal
uScanCode As Integer, ByRef lpbKeyState As Byte, ByRef lpwTransKey As
Integer, ByVal fuState As Integer) As Integer
Private Declare Function GetKeyboardState Lib "user32.dll" (ByRef
pbKeyState As Byte) As Long

Private Function GetCharFromKey(ByVal KeyCode As Integer) As String
Dim KeyBoardState(255) As Byte
Dim Out As Long
If GetKeyboardState(KeyBoardState(0)) <0 Then
If ToAscii(KeyCode, 0, KeyBoardState(0), Out, 0) <0 Then
If Out <= 255 Then
GetCharFromKey = Chr(Out)
Else
'GetCharFromKey =
Microsoft.VisualBasic.Left(StrConv(ChrW(Out), vbUnicode), 1)
GetCharFromKey =
Microsoft.VisualBasic.Left(StrConv(ChrW(Out), VbStrConv.None), 1)
End If
Else
GetCharFromKey = ""
End If
Else
GetCharFromKey = ""
End If
End Function


Dec 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
4
by: Andrew DeFaria | last post by:
I'm trying to use the onKeyDown event on a text field. I intersept the keystroke, interpret it and then do certain actions based on certain keys stuck. If a special key is stuck I replace the value...
2
by: paytam | last post by:
Hi all I want to use combine keys in my code such as ctrl+w or or Alt or F keys.What should I do? and is there any special data type which I use for this purpose?
90
by: Christoph Zwerschke | last post by:
Ok, the answer is easy: For historical reasons - built-in sets exist only since Python 2.4. Anyway, I was thinking about whether it would be possible and desirable to change the old behavior in...
4
by: Broeisi | last post by:
Hello, I'm trying to write a console based program in C in Linux. I want to use the function keys in my program, but I don;t know how to let the C program know when for exmaple the F1 key is...
9
by: Laphan | last post by:
Hi All I'm using the below to limit the input into a text box to just letters, numbers, hyphens and full stops, but I also need to allow the backspace, delete and arrow keys to come through. ...
5
by: Pieter | last post by:
Hi, How can I convert KeyCode's to the real character? For instance: the row of keys on a keyboard under the F-keys return as Keycode the Keys.Oem1, Keys.Oem2 etc... Depending on the keyboard...
4
by: Mo | last post by:
Hi, I am writing a console application to send a key sequence to an old clunky application on a regular interval using the windows scheduler. I can get it to work if it is a windows form...
2
by: John | last post by:
where are the following key codes in System.Windows.Forms.Keys : ; * = . , ' " thanks
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.