Page 1 of 1
simple square of my size, my location with my text
Posted: 08 Dec 2021, 05:54
by guldamkwak
I just want to show a simple square, possibly transparent, of my size, my location , with my text inside of it. Can you give me a simple code snippet illustrates how to do this?
thanks.
Re: simple square of my size, my location with my text
Posted: 08 Dec 2021, 06:32
by mikeyww
Code: Select all
square1 := square(100, 100, 200, "Yellow", "My text" , 20, 150)
square2 := square(500, 500, 100, "Red" , "Red square", 10)
square(x, y, boxEdge, color, text, fontSize, transparency := 255) { ; Show a colored square with text
; https://www.autohotkey.com/boards/viewtopic.php?p=433517#p433517
textY := (boxEdge - fontSize * A_ScreenDPI / 72) / 2
Gui, New, -Caption -Border +LastFound +HwndhWnd
Gui, Font, s%fontSize%
Gui, Margin, 0, 0
Gui, Add, Progress, w%boxEdge% h%boxEdge% c%color%, 100
Gui, Add, Text , xm y%textY% wp BackgroundTrans Center, %text%
Gui, Show, x%x% y%y%, Square
WinSet, Transparent, %transparency%
Return hWnd
}
Re: simple square of my size, my location with my text
Posted: 08 Dec 2021, 09:16
by guldamkwak
Can I make it without ?
- image.png (4.96 KiB) Viewed 506 times
mikeyww wrote: ↑08 Dec 2021, 06:32
Code: Select all
square1 := square(100, 100, 200, "Yellow", "My text" , 20, 150)
square2 := square(500, 500, 100, "Red" , "Red square", 10)
square(x, y, boxEdge, color, text, fontSize, transparency := 255) { ; Show a colored square with text
; https://www.autohotkey.com/boards/viewtopic.php?p=433517#p433517
textY := (boxEdge - fontSize * A_ScreenDPI / 72) / 2
Gui, New, -Caption -Border +LastFound +HwndhWnd
Gui, Font, s%fontSize%
Gui, Margin, 0, 0
Gui, Add, Progress, w%boxEdge% h%boxEdge% c%color%, 100
Gui, Add, Text , xm y%textY% wp BackgroundTrans Center, %text%
Gui, Show, x%x% y%y%, Square
WinSet, Transparent, %transparency%
Return hWnd
}
Re: simple square of my size, my location with my text
Posted: 08 Dec 2021, 09:59
by guldamkwak
i Want different sqaures show at the same time. How Can i do that?
mikeyww wrote: ↑08 Dec 2021, 06:32
Code: Select all
square1 := square(100, 100, 200, "Yellow", "My text" , 20, 150)
square2 := square(500, 500, 100, "Red" , "Red square", 10)
square(x, y, boxEdge, color, text, fontSize, transparency := 255) { ; Show a colored square with text
; https://www.autohotkey.com/boards/viewtopic.php?p=433517#p433517
textY := (boxEdge - fontSize * A_ScreenDPI / 72) / 2
Gui, New, -Caption -Border +LastFound +HwndhWnd
Gui, Font, s%fontSize%
Gui, Margin, 0, 0
Gui, Add, Progress, w%boxEdge% h%boxEdge% c%color%, 100
Gui, Add, Text , xm y%textY% wp BackgroundTrans Center, %text%
Gui, Show, x%x% y%y%, Square
WinSet, Transparent, %transparency%
Return hWnd
}
Re: simple square of my size, my location with my text
Posted: 08 Dec 2021, 16:55
by mikeyww
Try running this script by itself as a first step.
Code: Select all
square1 := square(100, 100, 200, "Yellow", "My text" , 20, 150)
square2 := square(500, 500, 100, "Red" , "Red square", 10)
square(x, y, boxEdge, color, text, fontSize, transparency := 255) { ; Show a colored square with text
; https://www.autohotkey.com/boards/viewtopic.php?p=433517#p433517
textY := (boxEdge - fontSize * A_ScreenDPI / 72) / 2
Gui, New, -Caption -Border +LastFound +HwndhWnd +Owner
Gui, Font, s%fontSize%
Gui, Margin, 0, 0
Gui, Add, Progress, w%boxEdge% h%boxEdge% c%color%, 100
Gui, Add, Text , xm y%textY% wp BackgroundTrans Center, %text%
Gui, Show, x%x% y%y%, Square
WinSet, Transparent, %transparency%
Return hWnd
}
- Output
- image211208-1700-001_cr-75.png (134.56 KiB) Viewed 477 times
Re: simple square of my size, my location with my text
Posted: 08 Dec 2021, 22:35
by guldamkwak
In that case, If I add more and more squares, than the former squares appear fisrt. For example square1 apperas first than square2
Re: simple square of my size, my location with my text
Posted: 09 Dec 2021, 05:42
by mikeyww
You can change the order to be whatever you want. What the script does: "i Want different sqaures show at the same time."