GuiClose Not Working. Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Ryagoft
Posts: 3
Joined: 24 May 2022, 14:49

GuiClose Not Working.

Post by Ryagoft » 24 May 2022, 14:57

Hello, I'm not very experienced with programming which is why I used SmartGUI to try and create a GUI with certain functions. I tried and implement a function into a checkbox with glabels but for some reason that I can't understand it causes GuiClose to not work and remove all of the minimize and close buttons as well as the ability to move the window. If anyone could help me it'd be a huge help. Here's the code:

Code: Select all

  
Gui, Font, S20 CDefault, Verdana
Gui, Add, Text, x122 y-1 w250 h50 , Test
Gui, Add, Text, x62 y-45 w0 h324 , Text
Gui, Font, S13 CDefault, Verdana
Gui, Font, S16 CDefault, Verdana
Gui, Add, Text, x22 y99 w180 h30 , Test
Gui, Font, S12 CDefault, Verdana
Gui, Add, CheckBox, x52 y139 w100 h30 , On/Off
Gui, Font, S20 CDefault, Verdana
Gui, Font, S16 CDefault, Verdana
Gui, Add, Text, x22 y189 w150 h30 , Test
Gui, Font, S12 CDefault, Verdana
Gui, Add, CheckBox, x12 y229 w160 h20 gFOV, Show/Don't show
Gui, Add, Text, x72 y269 w100 h30 , FOV Size
Gui, Add, Slider, x22 y299 w190 h70 , 25
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h379 w479, New GUI Window
Return

FOV: #NoEnv
#SingleInstance Force
SetBatchLines -1
SetTitleMatchMode 2

GAME_TITLE := "VALORANT"
X_OFFSET := 860
Y_OFFSET := 439

hCircle := makeCircle(0x00FF00, 200, 2, 180)
SetTimer MoveCircle, 100
Return

MoveCircle:
	if (hGame := WinActive(GAME_TITLE))
	{
		WinGetPos x, y, , , % "ahk_id " hGame
		Gui %hCircle%: Show, % Format("NoActivate x{} y{}", x + X_OFFSET, y + Y_OFFSET)
	}
	else
		Gui %hCircle%: Hide
Return

makeCircle(color, r := 400, thickness := 10, transparency := 254) {
	static HWND := MakeGui()

	; https://autohotkey.com/board/topic/7377-create-a-transparent-circle-in-window-w-winset-region/
	outer := DllCall("CreateEllipticRgn", "Int", 0, "Int", 0, "Int", r, "Int", r)
	inner := DllCall("CreateEllipticRgn", "Int", thickness, "Int", thickness, "Int", r - thickness, "Int", r - thickness)
	DllCall("CombineRgn", "UInt", outer, "UInt", outer, "UInt", inner, "Int", 3) ; RGN_XOR = 3
	DllCall("SetWindowRgn", "UInt", HWND, "UInt", outer, "UInt", true)

	Gui %HWND%:Color, % color
	Gui %HWND%:Show, xCenter yCenter w%r% h%r% NoActivate
	WinSet Transparent, % transparency, % "ahk_id " HWND

	return HWND
}

MakeGui() {
	Gui New, +E0x20 +AlwaysOnTop +ToolWindow -Caption +Hwndhwnd
	return hwnd
}
Return

GuiClose:
ExitApp

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GuiClose Not Working.  Topic is solved

Post by BoBo » 24 May 2022, 15:07

Have a try with this...

Code: Select all

MakeGui() {
	Gui New, +E0x20 +AlwaysOnTop +Hwndhwnd ; +ToolWindow -Caption
	return hwnd
}

Ryagoft
Posts: 3
Joined: 24 May 2022, 14:49

Re: GuiClose Not Working.

Post by Ryagoft » 24 May 2022, 15:26

@BoBo
Thank you very much, it worked! But I'm also having an issue where the GUI closes when I execute the script with the checkmark. Could you answer here or do I need to make a new thread?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GuiClose Not Working.

Post by BoBo » 24 May 2022, 16:01

Could you answer here or do I need to make a new thread?
If your new question would create "a thread in a thread" with a complete different subject a new thread would make sense, OTOH, that's up to you.

Question: are you sure that you've created that script yourself? :eh:

Once you've checked the checkbox the FOV-label will get triggered.
If the following condition fails the Gui will be hidden, so AFAICS it's not closed but invisible.

Btw,...

Code: Select all

#NoEnv
#SingleInstance Force
SetBatchLines -1
SetTitleMatchMode 2
I'd move these lines to the script's "auto-execute"-section AKA its top.

Ryagoft
Posts: 3
Joined: 24 May 2022, 14:49

Re: GuiClose Not Working.

Post by Ryagoft » 24 May 2022, 16:12

@BoBo
Again, thank you very much. I'll follow your advice with the code and I really appreciate your quick replies. And to answer your question: The script wasnt made by me, got it from another thread but wanted to use it on a gui for personal use.

Post Reply

Return to “Gaming Help (v1)”