Page 1 of 1
Adding Text Containing Line Breaks to a Gui Window
Posted: 15 Aug 2022, 12:28
by Alexander2
The following command adds the text “EXAMPLE” in the middle of a Gui window.
Code: Select all
gui add, text, xp yp wp hp cWhite Center 0x200 BackgroundTrans, EXAMPLE
Does anyone know what command can be used to add text which has line breaks?
For instance, the three lines
EXAMPLE
EXAMPLE
EXAMPLE
have to be added in the middle of a Gui window.
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 15 Aug 2022, 19:56
by mikeyww
Code: Select all
Gui, Add, Text,, EXAMPLE`nEXAMPLE`nEXAMPLE
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 16 Aug 2022, 12:02
by Alexander2
mikeyww wrote: ↑15 Aug 2022, 19:56
Code: Select all
Gui, Add, Text,, EXAMPLE`nEXAMPLE`nEXAMPLE
I have tried adding ‘n to the beginning of the text which is to start on a new line, but the text is not started on a new line.
The script includes an image as the background.
Code: Select all
Gui, +AlwaysOnTop -Caption
Gui, Add, Picture, w1280 h900, F:\Data\zzMacroinstr\Scripts\reminders and actions\_image.jpg
Gui, Font, s70, Arial Black
gui add, text, xp yp wp hp cWhite Center 0x200 BackgroundTrans, EXAMPLE `nEXAMPLE
gui show
return
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 16 Aug 2022, 12:53
by mikeyww
Debugging is easy, because you started with a working script, made several changes without testing each of them, and ended with a broken script. Start over, and add one change at a time; retest until it breaks. You then have your answer. Try deleting 0x200 as a start.
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 17 Aug 2022, 11:18
by Alexander2
mikeyww wrote: ↑16 Aug 2022, 12:53
Debugging is easy, because you started with a working script, made several changes without testing each of them, and ended with a broken script. Start over, and add one change at a time; retest until it breaks. You then have your answer. Try deleting
0x200 as a start.
I have deleted the parameter
0x200 from the script. Now the two words are displayed one below the other in the middle. However, they are displayed at the top of the window. Is it possible to display the words one below the other in the center of the window, as in the picture below?
- Untitled.png (10.9 KiB) Viewed 960 times
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 17 Aug 2022, 11:24
by mikeyww
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 18 Aug 2022, 11:37
by Alexander2
Thank you for the instructions. They deal with individual controls. But it seems as if there is no way to put more than one line of text automatically in the center. A user has to specify exact locations.
AutoHotkey can center a single line. Can it automatically do the same for more than one line? Perhaps there is a way to treat multiple lines as a single block of text rather than as separate controls?
Re: Adding Text Containing Line Breaks to a Gui Window
Posted: 18 Aug 2022, 11:55
by mikeyww
The Center option works horizontally. You would have to determine the position for vertical adjustment, but it is achievable with the commands that I mentioned.