In the "Control Panel > Ease of Access Centre > Make the keyboard easier to use" is an option to "Underline keyboard shortcuts and access keys."

Is there a way of programmatically switching this on and off?
I'm using Visual Basic Scripts, but can use .NET.
['https://Stackoverflow.com/questions/1328078', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1726/']
AFAIK, there's no way to toggle this option programmatically except for automating the approproate GUI actions (opening the Control Panel, switching the option on/off and applying the changes). In this case, I'd recommend using [AutoIt](http://www.autoitscript.com/autoit3/index.shtml) to automate the option switching.
It turns out you CAN programatically change the “underline keyboard shortcuts” option in your own application. You need to send the WM\_UPDATEUISTATE message to your main form according to the documentation found at: <https://learn.microsoft.com/en-us/windows/win32/menurc/wm-updateuistate>

Since you mentioned Visual Basic, here's how to do it:

```
Private Const WM_UPDATEUISTATE = &H128
Private Const UIS_CLEAR = &H2
Private Const UISF_HIDEACCEL = &H2
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As 
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

```

Then in the "Form\_Load" event send the message and it will activate keyboard shortcuts underlining for all controls and menus present on that form:

```
Private Sub Form_Load()
    PostMessage Me.hWnd, WM_UPDATEUISTATE, UIS_CLEAR + UISF_HIDEACCEL * 65536, 0
End Sub

```