Context menu shortcut letter not underlines Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joefiesta
Posts: 498
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Context menu shortcut letter not underlines  Topic is solved

28 Nov 2023, 13:33

The context menu items in this script should have a shortcut key underlined, as per doc. There are no underlined letters. Does anyone know why?

(of course, one must right click the gui to show the context menu.)

Code: Select all

   Gui, 3: Add, Text, x001 y007  w500   , testcontext.ahk
   Gui, 3: Show, x700 y500, Testcontext menu
   return
3GuiContextMenu:
   menu, context, add, &Options          , SetOptions
   menu, context, add                                           ; separator
   menu, context, add, &quit menu     , Context_cancel
   Menu, context, Show
   return
Context_cancel:
   return
SetOptions:
   return
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Context menu shortcut letter not underlines

28 Nov 2023, 13:50

I've noticed this in various situations with menus, but variably: the underlining sometimes appears and sometimes does not. I've attributed this to Windows rather than AHK, but I don't know with any certainty. I'd be interested in experts' explanations here, too.
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

28 Nov 2023, 14:41

mikeyww wrote:I'd be interested in experts' explanations here, too.
This quote from the User Guide for one of my programs explains it:
Sidebar: The underlines on a letter in each of the menu picks (as shown in the screenshot above) and the buttons in other screenshots in this User Guide are because that feature has been enabled in Windows (it is disabled by default). Here are the steps to enable it:
• Run Control Panel
• Open Ease of Access Center
• Click Make the keyboard easier to use
• Scroll down and tick the box that says Underline keyboard shortcuts and access keys
End Sidebar
Regards, Joe
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Context menu shortcut letter not underlines

28 Nov 2023, 14:50

Thanks, Joe. I checked that setting and was surprised to find it disabled on my system. I enabled it, and the script worked as expected after that.

Code: Select all

#Requires AutoHotkey v1.1.33
; Change how keyboard shortcuts work => Underline access keys when available
Run ms-settings:easeofaccess-keyboard
Last edited by mikeyww on 28 Nov 2023, 14:57, edited 1 time in total.
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

28 Nov 2023, 14:53

mikeyww wrote:I enabled it, and the script worked as expected after that.
Great news!
RussF
Posts: 1294
Joined: 05 Aug 2021, 06:36

Re: Context menu shortcut letter not underlines

28 Nov 2023, 14:55

I recently wrote a script where all the buttons on the gui had underlined shortcut keys. All the shortcuts worked, but I noticed that the underlines didn't actually appear until I had pressed the Alt key at least once.

I was not aware of the keyboard setting that @JoeWinograd mentioned, so I just set it on and ran the script in question. Lo and behold, the underlines appeared immediately. Way to go Joe! :bravo:

Russ
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

28 Nov 2023, 15:10

You're welcome, Russ, glad that did the trick for you. Regards, Joe
User avatar
V0RT3X
Posts: 243
Joined: 20 May 2023, 21:59
Contact:

Re: Context menu shortcut letter not underlines

28 Nov 2023, 17:44

This got me curious if Ease of Access Center's choices could be implemented through script. (I missed Mikeys code the 1st read through)
And that led to me realizing we can run CLSIDs and that we have a handy list in the documents.. https://www.autohotkey.com/docs/v1/misc/CLSID-List.htm
However, it appears Ease of Access Center's CLSID apparently requires the Ease of Access CLSID to run, which is not in the list in it's entirety. (just missing the \7)
I found both CLSID's at https://www.tenforums.com/tutorials/3123-clsid-key-guid-shortcuts-list-windows-10-a.html
and found how to apply together to open 'Ease of Access > Ease of Access Center' at https://groups.google.com/g/microsoft.public.windows.server.general/c/PhgLbEzFHdc?pli=1
Not exactly what I would even remotely call a bug, but just missing info about the back slash numbers, or at least I'm not seeing it.
Hope this helps anyone searching for CLSID info down the road...

Control Panel (Category view) - {26EE0668-A00A-44D7-9371-BEB064C98683}
Ease of Access - {26EE0668-A00A-44D7-9371-BEB064C98683}\7
Ease of Access Center - {D555645E-D4F8-4c29-A827-D93C859C4F2A}

And to open Ease of Access Center, combine the two as such...

Code: Select all

Run, ::{26EE0668-A00A-44D7-9371-BEB064C98683}\7\::{D555645E-D4F8-4C29-A827-D93C859C4F2A}

Of course you should just save yourself the trouble and just use what Mikey posted...short and sweet.
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Context menu shortcut letter not underlines

28 Nov 2023, 18:06

Good to hear.

There is a registry setting for this change as well, but I believe that, unlike the control-panel setting, this registry change would then require restarting the computer before the change would take effect. In any case, this is probably something that you would just change once and leave it, rather than needing any kind of script to toggle this setting. I can't imagine why anyone would disable this or even why it is not enabled by default, but I guess that preferences vary!
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

29 Nov 2023, 15:18

mikeyww wrote:something that you would just change once and leave it
Agree! That's certainly the case for me.
mikeyww wrote:why it is not enabled by default
Becasue it is yet another poorly chosen default by Microsoft...right up there with the default to "Allow the computer to turn off this device to save power" :)
mikeyww wrote:Run ms-settings:easeofaccess-keyboard
Good one, mikey, works a charm.
V0RT3X wrote:realizing we can run CLSIDs
Interesting thought!
V0RT3X wrote:to open Ease of Access Center, combine the two as such
Very clever! I did not know you could combine CLSIDs like that...thanks for your research on that.

Cheers, Joe
joefiesta
Posts: 498
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Context menu shortcut letter not underlines

29 Nov 2023, 17:31

awesome responses. SOLVED, but not without further questions.

And, yes! the Ease of Access setting mentioned fixed the problem for me.
What I don't understand, now is far, far more incomprehensible:

Some of my AHK macros already DID create context menu's with Shortcut Keys Underlined, with that option DISABLED.

As to running CLID's... that's old ihat for me. But,what intrigues me is the:
Run ms-settings:easeofaccess-keyboard That is because so many Win10 "facilities" when inspecting the process path, show, essentially, useless stuff, making their invocation what I thought was impossible without using the MS interfaces.

Where was this "Run ms-settings:easeofaccess-keyboard" discovered?
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

29 Nov 2023, 19:09

joefiesta wrote:And, yes! the Ease of Access setting mentioned fixed the problem for me.
Glad to hear it!
joefiesta wrote:Some of my AHK macros already DID create context menu's with Shortcut Keys Underlined, with that option DISABLED.]
Well, I suppose it's possible with use of the ampersand in Gui,Add,Text or the option in Gui,Font,Underline, for example:

Code: Select all

Gui,Add,Text,,Make&LetterUnderlined
Gui,Font,Underline
Gui,Add,Text,,F
Gui,Font,Norm
Gui,Add,Text,yp xp+6,irstLetterUnderlined
Gui,Show
Return
GuiClose:
GuiEscape:
ExitApp
That code results in this:

ahk underlined text.png
ahk underlined text.png (3.49 KiB) Viewed 528 times

But I haven't thought through how you would turn them into menu items, or even if that's possible. As far as I know, the normal ampersand usage on a menu item is not underlined unless the Windows option that we've been discussing is enabled. Because of that, I think the AHK V1 Help text on this is incomplete. It says this:
To underline one of the letters in a menu item's name, precede that letter with an ampersand (&). When the menu is displayed, such an item can be selected by pressing the corresponding key on the keyboard.
I think it should say something like this:
To underline one of the letters in a menu item's name, precede that letter with an ampersand (&). However, the underline will appear only if that option is enabled in Windows Ease of Access Center, which is disabled by default. When the menu is displayed, whether or not the underline appears, such an item can be selected by pressing the corresponding key on the keyboard.
joefiesta wrote:Where was this "Run ms-settings:easeofaccess-keyboard" discovered?
I don't know where or when or who. I have a note in my test files going back many years to this post at a different forum ("Asked 6 years, 10 months ago"):

https://superuser.com/questions/1168551/turn-on-off-bluetooth-radio-adapter-from-cmd-powershell-in-windows-10

That was for the Bluetooth setting. I have many others in my notes, although I can't say which ones I've tested:

Code: Select all

ms-settings:bluetooth
ms-settings:network-wifi
ms-settings:apps-volume
ms-settings:privacy-microphone
ms-settings:sound
ms-settings:sound-devices
ms-settings:privacy-webcam
ms-settings:batterysaver
ms-settings:batterysaver-usagedetails
ms-settings:batterysaver-settings
Regards, Joe
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Context menu shortcut letter not underlines

29 Nov 2023, 21:34

Good discussion.

I have found the access-key underlining in Windows to be inconsistent. Before I had enabled the setting, underlining still sometimes occurred, but seeming sporadically; I could not predict when it would happen.

Launch the Windows Settings app (ms-settings)
User avatar
JoeWinograd
Posts: 2209
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Context menu shortcut letter not underlines

29 Nov 2023, 22:05

Mikey,
Excellent link to Microsoft site for ms-settings app! Thanks much, Joe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: SmithyZoomZoom and 163 guests