Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / November 2007



Tip: Looking for answers? Try searching our database.

GetAsyncKeyState and [Alt Gr]

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Harvey Triana - 23 Oct 2007 14:58 GMT
Hello

I am using GetAsyncKeyState to read keyboard. Shift is easy to detect.
For example, key [1] has three characters:

[1]: "1"
[Shift][1]: "!"
[Alt Gr][1]: "|"

My question is how to detect that [Alt Gr] is down -?-

Thanks,
<Harvey Triana />
Thorsten Albers - 23 Oct 2007 16:54 GMT
Harvey Triana <harveytriana@hotmail.com> schrieb im Beitrag
<OmVpPzXFIHA.4956@TK2MSFTNGP06.phx.gbl>...
> I am using GetAsyncKeyState to read keyboard. Shift is easy to detect.
> For example, key [1] has three characters:
> [1]: "1"
> [Shift][1]: "!"
> [Alt Gr][1]: "|"
> My question is how to detect that [Alt Gr] is down -?-

[Alt Gr] is the same as [Alt] + [Shift] + [Ctrl], i.e. pressing [Alt Gr] is
the same as pressing [Alt], [Shift], and [Ctrl] at the same time.

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Per Larsen - 23 Oct 2007 17:37 GMT
On 23.10.2007 17:54, Thorsten Albers typed the following::
> Harvey Triana <harveytriana@hotmail.com> schrieb im Beitrag
> <OmVpPzXFIHA.4956@TK2MSFTNGP06.phx.gbl>...
[quoted text clipped - 7 lines]
> [Alt Gr] is the same as [Alt] + [Shift] + [Ctrl], i.e. pressing [Alt Gr] is
> the same as pressing [Alt], [Shift], and [Ctrl] at the same time.

It doesn't seem to work that way on my (norwegian) keyboard; e.g
pressing [Alt Gr]+'2' gives me '@', while [Alt Gr]+'´' then 'e' gives me
an 'é', while replacing with [Alt], [Shift], and [Ctrl] at the same time
with those keys give me no response.

Regards
PerL
Thorsten Albers - 23 Oct 2007 19:46 GMT
Per Larsen <perl.news@munged.invalid> schrieb im Beitrag
<FYWdnf4OmJmQvoPaRVnzvQA@telenor.com>...
> It doesn't seem to work that way on my (norwegian) keyboard; e.g
> pressing [Alt Gr]+'2' gives me '@', while [Alt Gr]+'´' then 'e' gives me
> an 'é', while replacing with [Alt], [Shift], and [Ctrl] at the same time
> with those keys give me no response.

I had an error in my previous posting: [Alt Gr] is [Alt] + [Ctrl], not
[Alt] + [Ctrl] + [Shift]. Try this combination.

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Per Larsen - 23 Oct 2007 20:24 GMT
> Per Larsen <perl.news@munged.invalid> schrieb im Beitrag
> <FYWdnf4OmJmQvoPaRVnzvQA@telenor.com>...
[quoted text clipped - 5 lines]
> I had an error in my previous posting: [Alt Gr] is [Alt] + [Ctrl], not
> [Alt] + [Ctrl] + [Shift]. Try this combination.

Yepp, that's the right one (well, when using the norwegian keyboard
setting, anyway). If I change to english keyboard setting it's another
story. I won't bother you (or anyone else on this list) with this as I
rather seldom use that keyboard setting.

Thanks!

Regards
PerL
Thorsten Albers - 23 Oct 2007 21:03 GMT
Per Larsen <perl.news@munged.invalid> schrieb im Beitrag
<VrSdnQULqubF14Pa4p2dnAA@telenor.com>...
> Yepp, that's the right one (well, when using the norwegian keyboard
> setting, anyway). If I change to english keyboard setting it's another
> story. I won't bother you (or anyone else on this list) with this as I
> rather seldom use that keyboard setting.

I don't know, but maybe that is due to that the US keyboard originally
didn't have an [Alt Gr] key. But on the other hand this AFAIK is long
ago...

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Karl E. Peterson - 23 Oct 2007 22:04 GMT
> Per Larsen <perl.news@munged.invalid> schrieb ...
>> Yepp, that's the right one (well, when using the norwegian keyboard
[quoted text clipped - 5 lines]
> didn't have an [Alt Gr] key. But on the other hand this AFAIK is long
> ago...

US keyboards still don't have that key, and it's a great way to play "Stump the
Marekan!"
Signature

.NET: It's About Trust!
http://vfred.mvps.org

Thorsten Albers - 23 Oct 2007 22:13 GMT
Karl E. Peterson <karl@mvps.org> schrieb im Beitrag
<ONJA$gbFIHA.3400@TK2MSFTNGP03.phx.gbl>...
> US keyboards still don't have that key, and it's a great way to play "Stump the
> Marekan!"

I think there are different versions of US keyboards available, aren't
there? At least the 'US international keyboard' according to Wikipedia
seems to have the [Alt Gr] key.

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Karl E. Peterson - 24 Oct 2007 00:02 GMT
> Karl E. Peterson <karl@mvps.org> schrieb ...
>> US keyboards still don't have that key, and it's a great way to play "Stump the
[quoted text clipped - 3 lines]
> there? At least the 'US international keyboard' according to Wikipedia
> seems to have the [Alt Gr] key.

This page?  http://en.wikipedia.org/wiki/Keyboard_layout

That's just a configuration.  Ain't no such beasts ever actually let loose in the
wild.  I've sure never seen one, and most folks (>99%?) in this country wouldn't
know an [Alt Gr] from an [Any].
Signature

.NET: It's About Trust!
http://vfred.mvps.org

Harvey Triana - 24 Oct 2007 22:15 GMT
> This page?  http://en.wikipedia.org/wiki/Keyboard_layout
great page! Thanks.

<ht />

>> Karl E. Peterson <karl@mvps.org> schrieb ...
>>> US keyboards still don't have that key, and it's a great way to play
[quoted text clipped - 10 lines]
> in the wild.  I've sure never seen one, and most folks (>99%?) in this
> country wouldn't know an [Alt Gr] from an [Any].
Per Larsen - 26 Oct 2007 00:26 GMT
On 24.10.2007 01:02, Karl E. Peterson typed the following::
>> Karl E. Peterson <karl@mvps.org> schrieb ...
>>> US keyboards still don't have that key, and it's a great way to play "Stump the
[quoted text clipped - 8 lines]
> wild.  I've sure never seen one, and most folks (>99%?) in this country wouldn't
> know an [Alt Gr] from an [Any].

Thanks for the nice link (which taught me a simple to get the 'µ' by
pressing [Alt Gr]+M on my [norwegian] keyboard)!

Also thanks to Thorsten for all useful info.

Signature

PerL

Thorsten Albers - 26 Oct 2007 09:12 GMT
Per Larsen <perl.news@munged.invalid> schrieb im Beitrag
<Rq-dndZyg6F1uLzaRVnzvQA@telenor.com>...
> Thanks for the nice link (which taught me a simple to get the 'µ' by
> pressing [Alt Gr]+M on my [norwegian] keyboard)!

In this case - another one which might be useful for you:
 http://www.microsoft.com/globaldev/keyboards/kbdno.htm

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Harvey Triana - 23 Oct 2007 17:49 GMT
Thanks for you help Thorsten. I have finished the application!

If IsKey(vbKeyMenu) And IsKey(vbKeyControl) Then Debug.Print "Alt Gr"
' works!

' partial code...
Private Const ISKEYBOOL As Integer = -32767
...
Private Function IsKey(pKey As Long) As Boolean
   IsKey = (GetAsyncKeyState(pKey) = ISKEYBOOL)
End Function

<Harvey Triana />

> Harvey Triana <harveytriana@hotmail.com> schrieb im Beitrag
> <OmVpPzXFIHA.4956@TK2MSFTNGP06.phx.gbl>...
[quoted text clipped - 8 lines]
> is
> the same as pressing [Alt], [Shift], and [Ctrl] at the same time.
Donald Lessau - 02 Nov 2007 12:25 GMT
> Thanks for you help Thorsten. I have finished the application!
>
[quoted text clipped - 7 lines]
>    IsKey = (GetAsyncKeyState(pKey) = ISKEYBOOL)
> End Function

If needed you can as well distinguish between Ctrl+Alt and AltGr.

Public VK_RMENU As Long = &HA5  '165
Public Function IsKeyDown(ByVal Key As Long) As Boolean
 IsKeyDown = CBool((GetAsyncKeyState(Key) And &H8000) = &H8000)
End Function
If IsKeyDown(VK_RMENU) Then Debug.Print "AltGr is pressed!"

Don
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.