Ampersand in Gui,Add,Button fails to underline character

Report problems with documented functionality
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 15:46

W7/64-bit
Version v1.1.14.03

With the Gui,Add,Button statement, an ampersand in front of a character in the button name is supposed to show an underline, indicating that Alt-TheUnderlinedCharacter will invoke the button (same as the button being clicked). However, the underline does not appear (although Alt-ThatCharacter does work). For example, this code will NOT show "F" underlined in the first button or "S" underlined in the second button (but Alt-F and Alt-S work):

Code: Select all

Gui,Add,Button,Default,&First
Gui,Add,Button,,&Second
Gui,Show,,ampersand underlining bug
Return

ButtonFirst:
MsgBox,4096,debug,first clicked
ExitApp

ButtonSecond:
MsgBox,4096,debug,second clicked
ExitApp

GuiClose:
GuiEscape:
ExitApp
A workaround is to send the Alt key after Gui,Show. In other words, this statement...

Send {Alt}

...placed right after the Gui,Show statement in the code above will cause the underlines on "F" and "S" to appear. Regards, Joe
Last edited by JoeWinograd on 30 Dec 2014, 17:00, edited 1 time in total.
guest3456
Posts: 3453
Joined: 09 Oct 2013, 10:31

Re: Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 15:52

this is not a bug afaik, this is standard Windows behavior for all Windows apps

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

Re: Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 16:19

I don't know. You may be right that this is standard Windows behavior, but I can say for sure that Microsoft itself (at least in some cases) puts the underlines on the characters in buttons. For example, here's a typical MS installation dialog with two buttons, both containing the underline for the Alt-character (on the "I" and "u"):

Image

I did not hit the Alt key to get the underlines - they were there when the dialog came up. Regards, Joe
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 17:11

But on the same system with the same setting, the AHK program does not show the underlines, while the MS program does. If the behavior is based on such a setting, I would expect both programs to behave the same - either both show it or both do not show it.

I reported this because I thought it was a bug, but if it's not, that's fine. I'm good with having my AHK script send the Alt key to activate the underlines for the user. Regards, Joe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 18:39

On win 7, Control panel -> ease of access center -> make the keyboard easier to use -> underline keyboard shortcuts and access keys.

Works for me
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: Ampersand in Gui,Add,Button fails to underline character

30 Dec 2014, 19:02

JoeWinograd wrote:You may be right that this is standard Windows behavior, but I can say for sure that Microsoft itself (at least in some cases) puts the underlines on the characters in buttons.
It's been my observation that Office is one of the worst offenders for not following the standard Windows behaviour in various cases. Office and Windows are developed by separate teams; that both teams are employed by Microsoft doesn't seem to count for much.

Try other programs, or parts of Windows. For instance, the Screen Resolution control panel in Windows 7 doesn't show underlines until I press Alt.
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Ampersand in Gui,Add,Button fails to underline character

31 Dec 2014, 00:38

> On win 7, Control panel -> ease of access center -> make the keyboard easier to use -> underline keyboard shortcuts and access keys.

Yes, that works, but these are programs that I'm distributing to end-users. I don't want to ask them to go through that procedure. I'm fine with putting the Send {Alt} statement in the distributed programs.

> Office is one of the worst offenders for not following the standard Windows behaviour

Good point! And such irony.

> Try other programs

Tried several. It varies. In Adobe Acrobat, Adobe Reader, and IrfanView, the underlines in menus don't show up until you hit Alt. In Mozilla Firefox, Mozilla Thunderbird, and GIMP, the underlines in menus are always present.

In any case, I'm on board with saying it's a feature, not a bug. Thanks to everyone for your quick responses - much appreciated! Regards, Joe
lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: Ampersand in Gui,Add,Button fails to underline character

31 Dec 2014, 04:29

Firefox, Thunderbird and GIMP are cross-platform programs which don't use the standard Windows controls.

Why are you working against this feature? Should the user not be expecting the underlines to be hidden when their system is set to behave that way? One could say that for any program to not respect the setting is a bug. That other programs don't conform to standard behaviour is no excuse.
User avatar
JoeWinograd
Posts: 2166
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Ampersand in Gui,Add,Button fails to underline character

31 Dec 2014, 12:08

> Firefox, Thunderbird and GIMP are cross-platform programs which don't use the standard Windows controls.

Fair enough.

> Why are you working against this feature?

Because the two programs that I have up all day and spend the most time in are Firefox and Thunderbird, so I'm really used to seeing the underlines.

> Should the user not be expecting the underlines to be hidden when their system is set to behave that way?

Good point!

> One could say that for any program to not respect the setting is a bug. That other programs don't conform to standard behaviour is no excuse.

Yes, one could say that. You've convinced me. I won't send the Alt key and will leave it up to the keyboard setting in Control Panel>Ease of Access Center. Thanks, Joe
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: Ampersand in Gui,Add,Button fails to underline character

21 Aug 2017, 08:49

1stly, I would not want to force the users make special changes.
2ndly, I have a form that is sometimes used to just take a quick view of a variable and is then immediately hotkey closed.
3rdly, I would very much like to have the underscore visible for ease of use and clarity sake.
4thly, I would not like to force the user to have to use their mouse at all ever.
5thly, Once [Alt] is pressed or Send {Alt} is used, it seems necessary to click the form with the mouse, as it becomes unresponsive
to my [Esc] to close, all my form hotkeys, (except the [Alt] ones) etc., until I physically click on the form.

So at the end of script section I want to use Send, {Alt} or some such, but then I want to add something to give control back to user,
like a simulated click, ControlClick, focus, activate, send lbutton, etc. I have tried many things, but I can't seem to get responsiveness
back without actually clicking on the form with the actual mouse, which I dislike the most of course.

Any ideas? I wonder what is actually happening to cause this to happen. All simulated clicks don't work?

Thanks
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: Ampersand in Gui,Add,Button fails to underline character

21 Aug 2017, 11:02

Why did you post this in a bug report from almost 3 years ago?!
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: Ampersand in Gui,Add,Button fails to underline character

21 Aug 2017, 17:07

Most, even "lexikos", in this old thread were of the opinion that this issue was not a "bug" but a feature. I agree with him. I am simply looking for a workaround for something that was well defined in this old thread. I am also pointing out that this [Alt] situation goes beyond the initial underscore display, but applies to any pressing of the [Alt] key. Also it seems that many posts are no longer able to be replied to. Do you think I should repost it as a new request for help? I would like to bring this post along for the ride, as it had a top AHK programmer participating.
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: Ampersand in Gui,Add,Button fails to underline character

21 Aug 2017, 17:21

Visioneer wrote:Do you think I should repost it as a new request for help?
Yes, definitely do that. Start a new thread with a clear title and some code example(as small as possible) that clearly shows the problem and you will get help.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: Ampersand in Gui,Add,Button fails to underline character

23 Aug 2017, 10:06

Ok obeeb,
I have posted another help request that just asks for a simple conversion function.
Kindly do not minimalize, trivialize or distract it.
Thanks
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: Ampersand in Gui,Add,Button fails to underline character

23 Aug 2017, 10:31

Visioneer wrote:Kindly do not minimalize, trivialize or distract it.
You have nothing to worry about, from now on I will stay as far away as I can from your help requests.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: Ampersand in Gui,Add,Button fails to underline character

23 Aug 2017, 18:43

Many thanks to wolf_II for his quick and elegant solution.

I wrote:
Gui, Add, Button, gSearchers, % "&" . UnderscoreLetter("S") . "earchers"

wolf_II wrote:
UnderscoreLetter(Letter="") { Return, Letter Chr(0x0332) }

https://autohotkey.com/boards/viewtopic ... 50#p166650

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 25 guests