Jump to content
Sign in to follow this  
Exit

HotKeySet() does not accept lower case letters in ASC notation. Feature or bug?

Recommended Posts

Exit

When using ASC notation in HotKeySet() for lower case letters,
the corresponding function is NOT fired.
Send() function accepts those values.

While ProcessClose("notepad.exe")
WEnd
ShellExecute("notepad.exe")
WinWait("[CLASS:Notepad]", "", 9)
Opt("SendKeyDelay", 0)
Opt("SendKeyDownDelay", 0)
Send("When using ASC notation in HotKeySet() for lower case letters, " & @CRLF)
Send("the corresponding function is NOT fired. " & @CRLF)
Send("Send() function accepts those values:" & @CRLF)
Send("Now sending {{}ASC 0x0041{}} ==> {ASC 0x0041} " & @CRLF)
Send("Now sending {{}ASC 0x0061{}} ==> {ASC 0x0061} " & @CRLF)
Send("Press ESC to Exit." & @CRLF)
Send("Please enter lower and upper case a/A  ==> ")

If Not HotKeySet("{ESC}", "_ESC") Then Exit MsgBox(Default, Default, "Hotkey ESC not set")
Func _ESC()
    While ProcessClose("notepad.exe")
    WEnd
    Exit MsgBox(64 + 262144, Default, "ESC pressed. OK to Exit", 3)
EndFunc   ;==>_ESC

If Not HotKeySet("{ASC 0x0041}", "_x41") Then Exit MsgBox(Default, Default, "Hotkey A(x41) not set")
Func _x41()
    MsgBox(64 + 262144, Default, "Hotkey A(x41) pressed", 1)
EndFunc   ;==>_x41

If Not HotKeySet("{ASC 0x0061}", "_x61") Then Exit MsgBox(Default, Default, "Hotkey a(x61) not set")
Func _x61()
    MsgBox(64 + 262144, Default, "Hotkey a(x61) pressed", 1)
EndFunc   ;==>_x61

While Sleep(100)
WEnd

HotKeySet() help says: Same format as Send().

Feature or bug ?
Any comments ?

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

I'm guessing that the ASC part doesn't work in HotKeySet, because you can use it to Send characters that aren't on your keyboard, so you can't set a hotkey to a key that doesn't exist. Looks like a documentation issue rather than a bug.


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
Exit

I'm guessing that the ASC part doesn't work in HotKeySet, because you can use it to Send characters that aren't on your keyboard, so you can't set a hotkey to a key that doesn't exist. Looks like a documentation issue rather than a bug.

But the lower case 'a' is definitely on my keyboard. :graduated:


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
Melba23

Exit,

You need to use Chr to set the HotKey, not Asc: ;)

HotKeySet(Chr(0x0061), "_Function") ; Lower case a

While 1
    Sleep(10)
WEnd

Func _Function()
    MsgBox(0, "Hi", "Pressed")
EndFunc
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Exit

You need to use Chr to set the HotKey, not Asc: ;)

Melba, I'm aware of the standard notation: hotkeyset("a","_Func") and its derivations.

I'm dealing with the special notation ("{ASC ....}")

I want to know, why {ASC 0x0041} is working and {ASC 0x0061} is failing to fire the function.

Both return 1 from the Hotkeyset(). See my sample is post #1.


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
Melba23

Exit,

As mentioned in the Help file, setting HotKeys with uppercase is not a good idea so I am not at all surprised that {ASC 0x0061} fails to fire a HotKey set with {ASC 0x0041}. It certainly does not work when you use the standard letters:

HotKeySet("A", "_Func")

While 1
    Sleep(10)
WEnd

Func _Func()
    MsgBox(0, "Hi", "Pressed")
EndFunc
For me that fires on "A" but not on "a". So why would it be different when you define the letter using {ASC 0x####}? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Exit

As mentioned in the Help file, setting HotKeys with uppercase is not a good idea so I am not at all surprised that {ASC 0x0061} fails to fire....

Melba,

{ASC 0x0061} is lowercase 'a'.

Please run my script in post #1 and see the result.

Uppercase fires and lowercase not. Strange?


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
Melba23

Exit.

Not at all strange because you get exactly the same result when you use the actual letters - as shown by my snippet above. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
trancexx

Melba, I'm aware of the standard notation: hotkeyset("a","_Func") and its derivations.

I'm dealing with the special notation ("{ASC ....}")

I want to know, why {ASC 0x0041} is working and {ASC 0x0061} is failing to fire the function.

Both return 1 from the Hotkeyset(). See my sample is post #1.

Because it's a bug.

Snippet from the other guy isn't relevant. When you use {ASC ...} with HotkeySet() then you will always register letter A regardless of the key specified. That's because "ASC" starts with letter "A".

;...

HotKeySet("{ASC 0x0042}", "Whatever") ; press A, which is not {ASC 0x0042} in any case
Func Whatever()
    MsgBox(32 + 262144, Default, "What hotkey was pressed?", 3)
EndFunc
;...
  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Melba23

trancexx,

Thank you for correctly analysing the problem. I have raised Trac ticket #2881 for it. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
trancexx

Sure, np.

Btw, the process is called "critical thinking". Try it sometimes.

If nothing, your smilies will have more sense.

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Melba23

<sigh> :(

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

Exit,

We have amended the documentation to explain that you cannot use the {ASC ####} notation with HotKeySet. In fact you never have been able to do so and you were the first to notice after all these years, so thanks. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×