How to do a strikethrough text in a GUI text component

Helpful script writing tricks and HowTo's
TheBeginner
Posts: 93
Joined: 19 Oct 2018, 12:05

How to do a strikethrough text in a GUI text component

Post by TheBeginner » 05 Feb 2023, 03:43

there are some methods out there on how to do a strike through text in a GUI text component, some methods I have seen
  • replace the letters with the equivalent pre-strike through unicode letters
  • use an image with the text already strike through
But there is a method of doing that without using pre-strike unicode letters, or images. it is possible to achieve just by using Gui text that will give you greater control.

first make sure that's your ahk script is saved with utf-8 with BOM
then you'll be able to use "—" character that creates a - like line just without the additional spaces to the left and right of that line

Working exampl

Code: Select all

#SingleInstance, force
Gui, margin, 40 40
Gui, Add, text, , Some text
Gui, Add, text, xp-1 yp+1 BackgroundTrans , ————————
Gui, show
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to do a strikethrough text in a GUI text component

Post by swagfag » 09 Feb 2023, 07:30

https://www.autohotkey.com/docs/v1/lib/Gui.htm#Font
just set the font to strikethrough
Peabianjay
Posts: 101
Joined: 07 Nov 2015, 22:50

Re: How to do a strikethrough text in a GUI text component

Post by Peabianjay » 16 Jul 2024, 17:59

Both solutions are good. They each have benefits and disadvantages.

Do this with "Font" (if you can!)

Code: Select all

Gui, Add, text, , Some text
Gui, Add, text, xp-1 yp+1 BackgroundTrans , ///////////
Often, the 'hardway' also has the benefit of learning techniques which can be applied to other stuff.
For example:

Code: Select all

	Gui, Add, Progress,	w50 h50	Backgroundblue 	center Disabled
	Gui, Add,     Text, xp  yp wp   hp  cred BackgroundTrans 	Center,  % text
Post Reply

Return to “Tutorials (v1)”