Jump to content
Sign in to follow this  
Zohar

HotKey Problem With Right Alt

Recommended Posts

Zohar

Hi
 
 
Let's say I assign a HotKey which is Ctrl-Alt-<Something>, for example Ctrl-Alt-[-].
 
If I press Ctrl-Alt-[-], then it works.
 
There is a problem tho:
If I set a HotKey for Alt-[-], then later on, when I press Alt-[-], I get the result for Ctrl-Alt-[-].
(and I did not press control,
and control is not stuck, neither physically, or in software)
 
 
Please note that this bug only happens when using the Right set of Alt/Ctrl keys,
it never happens to me on the Left Alt/Ctrl keys.
 
(meaning: If I press Left Alt-[-], I will always get the result for Alt-[-], and never it will mistake it for Ctrl-Alt-[-])
 
 
 
Please note that I gave an example with [-] as the key, but it happens with other keys as well..
 
 
Can it somehow be fixed?
 
Is it a known bug?
 
 
Thank you

Edited by Zohar
Title changed

Share this post


Link to post
Share on other sites
Exit

There is no right ALT key. It is called AltGr and is a combination of Cntl+Alt.

You may prove it by pressing AltGr+q --> @ and Cntl+Alt+q --> @

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
JScript

There is no right ALT key. It is called AltGr and is a combination of Cntl+Alt.

You may prove it by pressing AltGr+q --> @ and Cntl+Alt+q --> @

Also confirmed in keyboard PT-BR!

@Zohar

Post your code so we analyze better...

JS


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
Exit

A small reproducer to show the difference.

#include <misc.au3>
_HotKey("{ESC}") ; Exit script
_HotKey("!{-}") ; Alt + minus
_HotKey("^!{-}") ; AltGr + minus    or    Cntl + Alt + minus
Func _HotKey($hotkey = "")
    Switch @HotKeyPressed
        Case "{ESC}"
            Exit MsgBox(64 + 262144, Default, "Exit", 3)
        Case "!{-}"
            MsgBox(64 + 262144, Default, "Alt + minus pressed", 3)
        Case "^!{-}"
            MsgBox(64 + 262144, Default, (_IsPressed("A5") ? "AltGR" : "Cntl + Alt") & " + minus  pressed", 3)
        Case Else
            If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed)
            If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.")
    EndSwitch
EndFunc   ;==>_HotKey

While Sleep(100) ; here should be your application.
WEnd ; meanwhile, here is a dummy loop.

Note that AltGr (right Alt key) and Cntl+Alt share the same Hotkey definition and CASE statement "^!{-}"

Only Ispressed() function can show the difference.

btw, the skeleton of this code derives from my _Hotkey() skeleton and abbreviation. See >here.

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
BrewManNH

There is no right ALT key. It is called AltGr and is a combination of Cntl+Alt.

You may prove it by pressing AltGr+q --> @ and Cntl+Alt+q --> @

On a US English keyboard there most certainly is a right and left ALT key.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MikahS

@BrewManNH is absolutely correct. See the key list and they are declared with

{RALT}

and

{LALT}
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Exit

OK, I have a German keyboard and there is the key right to the spacebar labelled "AltGr"

                   

see: http://en.wikipedia.org/wiki/AltGr_key for the historical differences between US and foreign keyboards. 

IsPressed() function shows following keycode values:

Cntl (left)

00000011  17
000000A2  162

Cntl (right)

00000011  17
000000A3  163

 Alt (left)
 00000012  18
 000000A4  164

 AltGr (Alt right)
 00000011  17
 00000012  18
 000000A2  162
 000000A5  165

 Cntl (left) + Alt (left)
 00000011  17
 00000012  18
 000000A2  162
 000000A4  164

Cntl (right) + AltGr (Alt right)

00000011  17
00000012  18
000000A2  162
000000A3  163
000000A5  165

 


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
MikahS

It is best to know what OP is using :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Exit

 

@BrewManNH is absolutely correct. See the key list and they are declared with

{RALT}

and

{LALT}

 

Did you tried RALT and LALT in a hotkey definition. I had no luck. :


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
MikahS

The following hotkeys cannot be set:
 

Ctrl+Alt+Delete It is reserved by Windows F12 It is also reserved by Windows, according to its API.

NumPad's Enter Key Instead, use {Enter} which captures both Enter keys on the keyboard.

Win+B,D,E,F,L,M,R,U; and Win+Shift+M These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above.

Alt, Ctrl, Shift, Win These are the modifier keys themselves!

Other Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Zohar

Hi All

 

Thank you for all the Info.

 

First of all:

There is no right ALT key. It is called AltGr and is a combination of Cntl+Alt.

My keyboard has Ctrl and Alt left to the SpaceBar, and another pair of Ctrl and Alt right to the SpaceBar.

The Right Alt is labelled "Alt", and not "AltGr".

Also in all applications, when I press that Alt with some key(for example Alt-F, for the file menu, etc),

I get the result of Alt-F, and not Ctrl-Alt-F..

 

Let me make a short code, and I'll paste it here,

tho please note that this problem happens not 100% of the time, so I will have to test it many times hopefully my short code will reproduce the problem.

Share this post


Link to post
Share on other sites
MikahS

Paste the code that gives you problems in the first place :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Exit

@Zohar

Apparently you have not read the wiki entry. Here again  

http://en.wikipedia.org/wiki/AltGr_key#Control_.2B_Alt_as_a_substitute

Quotation:

Originally, US PC keyboards (specifically, the US 101-key PC/AT keyboards) did not have an AltGr key because that was relevant to only non-US markets; they simply had "left" and "right" Alt keys.

The right Alt key is usually an equivalent of the AltGr key, as both of them share the same scancode

Yes, US keyboards have the right Alt key labelled "ALT", but the scancode is equvalent to the international "AltGr" key.

Here again the scancodes:

Left Alt.

Alt (left)
 00000012  18
 000000A4  164

 Right Alt
 00000011  17
 00000012  18
 000000A2  162
 000000A5  165


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
BrewManNH

@Zohar

Apparently you have not read the wiki entry. Here again  

http://en.wikipedia.org/wiki/AltGr_key#Control_.2B_Alt_as_a_substitute

Quotation:

Originally, US PC keyboards (specifically, the US 101-key PC/AT keyboards) did not have an AltGr key because that was relevant to only non-US markets; they simply had "left" and "right" Alt keys.

The right Alt key is usually an equivalent of the AltGr key, as both of them share the same scancode

Yes, US keyboards have the right Alt key labelled "ALT", but the scancode is equvalent to the international "AltGr" key.

Here again the scancodes:

Left Alt.

Alt (left)

 00000012  18

 000000A4  164

 Right Alt

 00000011  17

 00000012  18

 000000A2  162

 000000A5  165

Who  ever wrote that is wrong. The right ALT key definitely does NOT have the same scan code as the ALTGr keycode. When I ran your script in post #6 the only time I get the message box for "ALTGr + -" is when I press either CTRL key the Right ALT key, and the minus key. So, even though the ALT is probably the same keycode as half of the ALTGr key, on a US English keyboard in Win7 you do not get the CTRL + ALT at the same time by pressing the right ALT key by itself.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Zohar

Hi All

 

I want to create a reproducer code, but there's a small problem.

Because this phenomenon/bug doesn't happen 100% of the time(in fact it happens only 10-20% of the time), then I first need to reproduce it on my original code.

(with my original code, this problem happens for several years now :) but it's relatively rare, and only with the right Alt/Ctrl, so I put it away, until now when I decided to get rid of that problem too)

 

Since it happens once in a while, then even If I create a minimal reproducer code, I don't know when it will reproduce the problem.

 

I am looking to find something that tells me when this problem happens, so I can also create and test the reproducer code at the same time/condition.

 

BTW, the fact that it happens only once in a while, makes me think that it's indeed a bug.

(if it was 100% of the time, then we could say it's a desired behavior and not a bug)

 

I tested now gain and it doesn't happen, so I will try again every few hours, till it happens,

and then create the reproducer, hopefully it will happen there too,

and then I will paste it here...

 

Thank you

Edited by Zohar

Share this post


Link to post
Share on other sites
Exit

I made a little script to get the hex keycodes of the 4 Cntl / Alt keys.
Please press the key / keycombinations for some seconds and record the codes for each combination, If they are different of those in the comment (German keyboard), 
Then please post them here. Thanks.

#include <GUIConstantsEx.au3>
#include <misc.au3>
Opt("GUICoordMode", 0) ;1=absolute, 0=relative, 2=cell
Local $hDLL = DllOpen("user32.dll")
Local $a[6][3]
GUICreate("Press left and/or right Cntl and/or Alt ", 300, 45)
$a[0][0] = "11"
$a[1][0] = "12"
$a[2][0] = "A2"
$a[3][0] = "A3"
$a[4][0] = "A4"
$a[5][0] = "A5"

$a[0][1] = GUICtrlCreateLabel("11", 20, 20, 40, 20)
$a[1][1] = GUICtrlCreateLabel("12", +40, -1, -1, -1)
$a[2][1] = GUICtrlCreateLabel("A2", +40, -1, -1, -1)
$a[3][1] = GUICtrlCreateLabel("A3", +40, -1, -1, -1)
$a[4][1] = GUICtrlCreateLabel("A4", +40, -1, -1, -1)
$a[5][1] = GUICtrlCreateLabel("A5", +40, -1, -1, -1)
For $i = 0 To 5
    GUICtrlSetState($a[$i][1], 32) ; hide labels
Next
GUISetState(@SW_SHOW)

While 1
    If _IsPressed("1B", $hDLL) Then ExitLoop
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    For $i = 0 To 5
        GUICtrlSetState($a[$i][1], 32)
        $a[$i][2] = _IsPressed($a[$i][0], $hDLL)
    Next
    For $i = 0 To 5
        If $a[$i][2] Then GUICtrlSetState($a[$i][1], 16)
    Next
    Sleep(200)
WEnd
DllClose($hDLL)
#cs
    Hex-Codes on my German keyboard:
    Please post your codes, if different.
    Cntl L         11    A2
    Cntl R         11       A3
    Alt  L            12       A4
    Alt  R         11 12 A2       A5   is labelled AltGr
    Cntl L + ALT L 11 12 A2    A4
    Alt L + Cntl L 11 12 A2    A4
    Cntl R + Alt R 11 12    A3    A5
    Alt R + Cntl R 11 12 A2 A3    A5
    
    US English keyboard
L-CTRL = 11 A2
R-CTRL = 11 A3
L-ALT =  12 A4
R-ALT =  12 A5   is labelled ??? (AltGr or Alt) 
Pressing them in any combination always results in a combination of the above codes
For example, Right Alt and L-CTRL = 11 12 A2 A5.
    
#ce
Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
jchd

Something I wasn't aware of: with a french keyboard the result depends on the order of keydowns for right AltGr + R-Ctrl.

R-Ctrl first then R-AltGr: 11  12        A3  A5

R-AltGr first then R-Ctrl: 11  12  A2  A3  A5


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Exit

Same with the German keyboard. Modified comment in post #18

At least, French keyboard has also a AltGr key. :thumbsup:

Waiting for a US keyboard result.


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×