Jump to content

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


Exit
 Share

Recommended Posts

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

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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.

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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?

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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
;...

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

trancexx,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

<sigh> :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...