Inclusion of Spaces in Button Names Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Inclusion of Spaces in Button Names

Post by Alexander2 » 24 Oct 2021, 12:48

The following script does not work because there is a space in the name of the button. Can someone explain how to include spaces in button names when there is more than one word in the name?

Code: Select all

Gui, ContMenu1:New
Gui, ContMenu1:Color, white
Gui, ContMenu1:Font, s14
Gui, ContMenu1:Add, Button, , example button
Gui, ContMenu1:Show
return
ContMenu1Buttonexample button:
Gui, ContMenu1:Submit
return

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Inclusion of Spaces in Button Names

Post by mikeyww » 24 Oct 2021, 12:50

Code: Select all

Gui, ContMenu1:New
Gui, ContMenu1:Font, s14
Gui, ContMenu1:Add, Button, , example button
Gui, ContMenu1:Show
Return

ContMenu1ButtonExampleButton:
Gui, ContMenu1:Submit
MsgBox, Done!
Return
The secret is in the documentation.
If the text on the button contains spaces or any of the characters in the set &`r`n`t`, its automatic label omits those characters.

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Inclusion of Spaces in Button Names

Post by Alexander2 » 24 Oct 2021, 14:11

Thank you. Is it also possible to add periods and the slash character in the names of buttons? The following buttons which contain abbreviated words do not work:

Code: Select all

Gui, ContMenu1:New
Gui, ContMenu1:Color, white
Gui, ContMenu1:Font, s14
Gui, ContMenu1:Add, Button, , Card. Numb.
Gui, ContMenu1:Add, Button, , 200 руб./стр.
Gui, ContMenu1:Show
return
ContMenu1ButtonCardNumb:
Gui, ContMenu1:Submit
return
ContMenu1Button200рубстр:
Gui, ContMenu1:Submit
return

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Inclusion of Spaces in Button Names  Topic is solved

Post by mikeyww » 24 Oct 2021, 14:14

Code: Select all

Gui, ContMenu1:New
Gui, ContMenu1:Color, white
Gui, ContMenu1:Font, s14
Gui, ContMenu1:Add, Button,, Card. Numb.
Gui, ContMenu1:Show
Return

ContMenu1ButtonCard.Numb.:
Gui, ContMenu1:Submit
MsgBox, 64, Done, Done!
Return
Another option is a g-label. Explained: Button

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Inclusion of Spaces in Button Names

Post by Alexander2 » 25 Oct 2021, 09:24

Thank you. I had not realized that periods and slashes should be preserved when writing a label name based on the name of a button.

Post Reply

Return to “Ask for Help (v1)”