Virtual-Key Codes for swedish chars å,ä and ö

P

Peter B

Hi!

I am using VS and C# to create an application in which I want the user to be
able to type swedish characters with the hardware keyboard. Since the
keyboard doesn't have any of those keys I was hoping to produce the swedish
characters from my code after I receive a certain key value from the user.

I am using keybd_event from coredll.dll but I don't understand how I can
produce a character of my own liking. I can't find the swedish characters
(or any other special chars) in the list below of virtual keys codes.

keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo):
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be synthezised
with the keybd_event method? Is there another method that can be used to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
P

Peter B

You may have missed the line "...hardware keyboard..." :)

I am not talking about the SIP, but as it can produce national chars I am
sure I could from my code :) Maybe I could use the api's behind the SIP?

/ P

éric said:
Are there not third party keyboards that type International characters?
this might be an option

http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
or
http://swedish.pocket-pc.penreader.com/Language_Extender_Swedish.html

éric

Peter B said:
Hi!

I am using VS and C# to create an application in which I want the user
to
be
able to type swedish characters with the hardware keyboard. Since the
keyboard doesn't have any of those keys I was hoping to produce the swedish
characters from my code after I receive a certain key value from the user.

I am using keybd_event from coredll.dll but I don't understand how I can
produce a character of my own liking. I can't find the swedish characters
(or any other special chars) in the list below of virtual keys codes.

keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo):
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be synthezised
with the keybd_event method? Is there another method that can be used to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
P

Paul G. Tobey [eMVP]

Peter,

I've not done it this way (I've always modified the keyboard driver), but
you should be able to generate a given key code with Alt+<#>+<#>+<#>, as
long as the character is in the ASCII code range, which I think those are.
This is the equivalent of holding down the Alt key and pressing the number
keys on the numeric keypad to generate a code. You'll need to make sure
that the characters that you send are in the right order (Alt goes down,
then numeric keypad first number down, then up, etc., finally Alt goes up).

Alternatively, you may be able to use PostKeybdMessage() to send the Unicode
key directly, but I think that, without the keyboard driver knowing about
Swedish, that probably won't work. There are a lot of little things that
you can try with it, though, so maybe I'm wrong about that.

Paul T.

Peter B said:
You may have missed the line "...hardware keyboard..." :)

I am not talking about the SIP, but as it can produce national chars I am
sure I could from my code :) Maybe I could use the api's behind the SIP?

/ P

éric said:
Are there not third party keyboards that type International characters?
this might be an option
http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be synthezised
with the keybd_event method? Is there another method that can be used to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
É

éric

hardware keyboard..." :)

sorry... I missed that!
but yeah if they can do you should to!!! <-- not much help but a few words
of encouragement

Regards,

éric

Peter B said:
You may have missed the line "...hardware keyboard..." :)

I am not talking about the SIP, but as it can produce national chars I am
sure I could from my code :) Maybe I could use the api's behind the SIP?

/ P

éric said:
Are there not third party keyboards that type International characters?
this might be an option
http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be synthezised
with the keybd_event method? Is there another method that can be used to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
P

Peter B

Hi Toby, thanks for your help!

As it seems, Alt+1+3+4, which should return the swedish char å, only returns
a square symbol. So generating the special chars directly from the keyboard
doesn't seem to work. But I don't think that is what you suggested. I will
investigate how you send the "Alt-down, NUM1-d/u, NUM2-d/u, NUM3-d/u,
Alt-up"-sequence with the keybd_event-method, as it is now I have no idea
how to do that :)

The keyboard-driver shouldn't matter in this case. I mean, I am getting a
key event of any sort (for example "Ctrl + A" to simulate Å), and after
checking that I have a text-control in focus, send some sort of signal
(using keybd_event or any other method??) to create the swedish char (just
like the SIP does ). Thinking about it, it shouldn't be too hard, just have
to find the correct method, or?

regards,

Peter



Paul G. Tobey said:
Peter,

I've not done it this way (I've always modified the keyboard driver), but
you should be able to generate a given key code with Alt+<#>+<#>+<#>, as
long as the character is in the ASCII code range, which I think those are.
This is the equivalent of holding down the Alt key and pressing the number
keys on the numeric keypad to generate a code. You'll need to make sure
that the characters that you send are in the right order (Alt goes down,
then numeric keypad first number down, then up, etc., finally Alt goes up).

Alternatively, you may be able to use PostKeybdMessage() to send the Unicode
key directly, but I think that, without the keyboard driver knowing about
Swedish, that probably won't work. There are a lot of little things that
you can try with it, though, so maybe I'm wrong about that.

Paul T.

Peter B said:
You may have missed the line "...hardware keyboard..." :)

I am not talking about the SIP, but as it can produce national chars I am
sure I could from my code :) Maybe I could use the api's behind the SIP?

/ P
http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be synthezised
with the keybd_event method? Is there another method that can be
used
 
P

Paul G. Tobey [eMVP]

It depends on what is being sent. The process of converting a scan code to
the actual character that is to be returned *is* handled by the keyboard
driver. I don't know what will happen if you generate a scan code that is
not in the list that the driver knows about, for example.

The SIP is a special case. I guess that you might be able to figure out
what the SIP code does when you return a character to it and try to do the
same thing...

Paul T.

Peter B said:
Hi Toby, thanks for your help!

As it seems, Alt+1+3+4, which should return the swedish char å, only returns
a square symbol. So generating the special chars directly from the keyboard
doesn't seem to work. But I don't think that is what you suggested. I will
investigate how you send the "Alt-down, NUM1-d/u, NUM2-d/u, NUM3-d/u,
Alt-up"-sequence with the keybd_event-method, as it is now I have no idea
how to do that :)

The keyboard-driver shouldn't matter in this case. I mean, I am getting a
key event of any sort (for example "Ctrl + A" to simulate Å), and after
checking that I have a text-control in focus, send some sort of signal
(using keybd_event or any other method??) to create the swedish char (just
like the SIP does ). Thinking about it, it shouldn't be too hard, just have
to find the correct method, or?

regards,

Peter



Paul G. Tobey said:
Peter,

I've not done it this way (I've always modified the keyboard driver), but
you should be able to generate a given key code with Alt+<#>+<#>+<#>, as
long as the character is in the ASCII code range, which I think those are.
This is the equivalent of holding down the Alt key and pressing the number
keys on the numeric keypad to generate a code. You'll need to make sure
that the characters that you send are in the right order (Alt goes down,
then numeric keypad first number down, then up, etc., finally Alt goes up).

Alternatively, you may be able to use PostKeybdMessage() to send the Unicode
key directly, but I think that, without the keyboard driver knowing about
Swedish, that probably won't work. There are a lot of little things that
you can try with it, though, so maybe I'm wrong about that.

Paul T.
http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be
synthezised
with the keybd_event method? Is there another method that can be
used
to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
P

Peter B

Oh dear, have I been complicating things slightly here :)

I realized that all I need to do is append the special character to the
controls text property, I don't need to send any keyboard-events :) Since
the Ctrl_KeyDown event handler gives me the sender control, I can simply add
the char to it's text.

Instead I am trying to find out how to determine if the control is editable,
i.e. a control that can receive input text such as textbox and combobox. The
keydown event handler handles events from all different controls, and I
don't want to send the char to a buttons or forms text property :)

/ Peter


Paul G. Tobey said:
It depends on what is being sent. The process of converting a scan code to
the actual character that is to be returned *is* handled by the keyboard
driver. I don't know what will happen if you generate a scan code that is
not in the list that the driver knows about, for example.

The SIP is a special case. I guess that you might be able to figure out
what the SIP code does when you return a character to it and try to do the
same thing...

Paul T.

Peter B said:
Hi Toby, thanks for your help!

As it seems, Alt+1+3+4, which should return the swedish char å, only returns
a square symbol. So generating the special chars directly from the keyboard
doesn't seem to work. But I don't think that is what you suggested. I will
investigate how you send the "Alt-down, NUM1-d/u, NUM2-d/u, NUM3-d/u,
Alt-up"-sequence with the keybd_event-method, as it is now I have no idea
how to do that :)

The keyboard-driver shouldn't matter in this case. I mean, I am getting a
key event of any sort (for example "Ctrl + A" to simulate Å), and after
checking that I have a text-control in focus, send some sort of signal
(using keybd_event or any other method??) to create the swedish char (just
like the SIP does ). Thinking about it, it shouldn't be too hard, just have
to find the correct method, or?

regards,

Peter



I
am
http://ectaco.com/software/item.php3?refid=0&rfr_id=1&rqt_id=2&pagelang=23&lang=19&softid=306&scat=7
the
user Since
the
how
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefKeybd_event.asp]
Virtual Key Codes:
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/ht
ml/cerefvirtualkeycodes.asp]

Is the key codes in the list above the only chars that can be
synthezised
with the keybd_event method? Is there another method that can be used
to
send more general (ASCII, Unicode) chars???

regards,

Peter
 
P

Peter B

Here's the code I use if anyone is interested. This examples waits for
keydown of key F9, this can of course be changed to a key or key-combination
of your liking. Are there any complications with using key_down?


private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.F9: // Swedish Ö
// Check if this is an input-control
if( sender is TextBox )
{
TextBox tBox = (TextBox)sender;
int pos = tBox.SelectionStart;
// Must position at correct place..
if( e.Shift )
{
tBox.Text = tBox.Text.Insert(
tBox.SelectionStart,
"Ö" );
tBox.SelectionStart = pos + 1;
}
else
{
tBox.Text = tBox.Text.Insert(
tBox.SelectionStart,
"ö" );
tBox.SelectionStart = pos + 1;
}
}
else if( sender is ComboBox )
{
// Highlight items starting with ö or Ö
}
break;
default:
break;
}
}

best regards,

Peter
 

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