Updating text in GUI with coordinates Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
picklepissjar
Posts: 20
Joined: 22 Oct 2022, 10:03

Updating text in GUI with coordinates

Post by picklepissjar » 14 Nov 2022, 22:26

I'm trying to update a gui with text "Coordinates: (x1, y1)(x2, y2)", but only the first coordinates are showing, despite the MsgBox of the variable showing the correct output.

Code: Select all

	Gui, clippos:-Caption +Disabled +ToolWindow
	Gui, clippos:Font, s15
	Gui, clippos:Add, Text, cWhite vselrect, "Coordinates: (0, 0) (0, 0)"
	Gui, clippos:Color, Black
	x1 := 100, x2 := 200, y1 := 300, y2 := 400
	capcord := "Coordinates: (" x1 ", " y1 ") (" x2 ", " y2 ")"
	MsgBox % capcord									; Shows correctly 
	GuiControl, clippos:Text, selrect, %capcord%		; Shows only first coord
	Gui, clippos:Show, % "x" A_ScreenWidth // 40 " y" A_ScreenHeight //  27
I really don't understand it. :headwall:
If I remove the space between the parentheses only the "Coordinates: (100, " shows

If I remove the quotations around x2 i.e. "Coordinates: (" x1 ", " y1 ") ( x2 , " y2 ")" Then up to the 2nd ( shows, but not the "x2"
If I remove the space between the 2nd ( and x2 ....................... ") (x2 , "......... Then Only the first coordinates show

gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: Updating text in GUI with coordinates  Topic is solved

Post by gregster » 14 Nov 2022, 22:58

Your text control originally autosizes to the initial text. Later, when replacing the text, it won't resize automatically and the text will linebreak (which you don't see without enlarging the height).

You could size the text control big enough from the start with the w option, or you could resize the control later with GuiControl, Move - but since you know the maximum of the needed width from the start (max coordinate values), I would make the original text control already wide enough.

picklepissjar
Posts: 20
Joined: 22 Oct 2022, 10:03

Re: Updating text in GUI with coordinates

Post by picklepissjar » 14 Nov 2022, 23:26

I definitely would not have thought of that!
:D TYVM

Post Reply

Return to “Ask for Help (v1)”