How to add a rectangle in gui without filled color Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alexsu
Posts: 97
Joined: 16 Jul 2020, 05:32

How to add a rectangle in gui without filled color

Post by alexsu » 13 Mar 2023, 19:49

Hello, I want add a rectangle in gui, this rectangle doesn't have filled color, the stroke is 2, stroke color is red
rectangle position and size x10 y10 w100 h80

How to do it ? Appreciate your help.

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

Re: How to add a rectangle in gui without filled color  Topic is solved

Post by mikeyww » 13 Mar 2023, 20:37

Code: Select all

#Requires AutoHotkey v1.1.33
image := A_ScriptDir "\test2.gif"
Gui -DPIScale
Gui Margin, 10, 10
Gui Color, Yellow
Gui Add, Pic, AltSubmit, % image
Gui Show
image230313-2144-001.png
Output
image230313-2144-001.png (2.7 KiB) Viewed 544 times
Attachments
test2.gif
Test image
test2.gif (310 Bytes) Viewed 552 times

Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to add a rectangle in gui without filled color

Post by Rohwedder » 14 Mar 2023, 03:21

Hallo,
try:

Code: Select all

Gui, 1:Show, w250 h150
xr := 10, yr := 10, wr := 100, hr := 80 ; rectangle
sr := 2 ; stroke of rectangle
Gui, r:+Parent1 -Caption +LastFound -SysMenu +ToolWindow
Gui, r:Color, Red
Gui, r:Show,% "w"wr " h"hr " x"xr " y"yr
WinSet, Region,% "0-0 "wr "-0 "wr "-"hr " 0-"hr " 0-0 "sr "
-"sr " "wr-sr "-"sr " "wr-sr "-"hr-sr " "sr "-"hr-sr " "sr "-"sr


Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to add a rectangle in gui without filled color

Post by Rohwedder » 25 Mar 2023, 10:34

@Hellbent
What is the purpose of calculating x2 ?
Draw_Outline(Gui_Name,x,y,w,h,Color:="Black",thickness:=1){
x2:=X+W-thickness
Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" W " h" thickness " Background" Color
Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" thickness " h" H " Background" Color
Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y+H-thickness " w" W " h" thickness " Background" Color
Gui,% Gui_Name ":Add",Progress,% "x" X+W-thickness " y" Y " w" thickness " h" H " Background" Color
}

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: How to add a rectangle in gui without filled color

Post by Hellbent » 25 Mar 2023, 12:22

Rohwedder wrote:
25 Mar 2023, 10:34
@Hellbent
What is the purpose of calculating x2 ?
When I write code, I first think broadly about the problem and try to get a general sense of what I need to do, the steps I need to take, the variables I'm going to need, etc.

What you have there is likely a remnant of where planning meets writing. I have noticed that a few times now too (in regards to this code) and my best guess is that I left it there as a pointer to a later me that I might want to do it with new variables rather than have the calculation done in the controls options :shrug:

This is likely what I started out planning on doing but for whatever reason I changed my mind as I wrote the code.

Code: Select all

Draw_Outline(Gui_Name,x,y,w,h,Color:="Black",thickness:=1){
	x2:=X+W-thickness
	y2:=Y+H-thickness
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" W " h" thickness " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" thickness " h" H " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" y2 " w" W " h" thickness " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" x2 " y" Y " w" thickness " h" H " Background" Color 	
}
So to finally answer your question lol
It has no purpose.

In all honesty, It's not the first time that I have created variables that I don't end up using and it won't be the last lol.

Post Reply

Return to “Ask for Help (v1)”