How to perform two different tasks when I press close buttons of two different GUIs created by same script? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

How to perform two different tasks when I press close buttons of two different GUIs created by same script?

19 May 2019, 05:36

Hello Friends...

As far as I know GuiClose label is an inbuilt label which is associated with close button for any Gui window. NOW, suppose i have codes for two guis in same script and i want that when i press close button for first gui then it should show msgbox saying you pressed close button for first gui. And if i press close button for second gui then it should pop up that you pressed close button for second gui.

My codes are these-

Code: Select all

1::
Gui Add, Edit, x165 y47 w181 h67
Gui Add, Button, x168 y153 w177 h55, &OK

Gui Show, w456 h320, First Gui
Return

GuiClose:
MsgBox you pressed close button for first gui
return


2::
Gui r:Add, Edit, x165 y47 w181 h67
Gui r:Add, Button, x168 y153 w177 h55, &OK

Gui r:Show, w456 h320, Second Gui
Return

GuiClose:    ; Here it is showing error that- Duplicate Label
MsgBox you pressed close button for second gui
return
Both Guis look like this-

19_05_19 @4_05_09.PNG
19_05_19 @4_05_09.PNG (51.97 KiB) Viewed 773 times


In the above codes you can see that i have two different guis. First gui is shown when i press 1 key and second gui is shown when i press 2 key. But here the problem is I want that when i press the close button of first gui then it should show the msgbox you pressed close button for first gui and when i press the close button of second gui then it should show the msgbox you pressed close button for second gui. But these codes are producing error of Duplicate label. This script is accepting only one GuiClose Lable which can be associated with only one gui.

Please help and guide to solve my problem.

Thanks a lot..
I don't normally code as I don't code normally.
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: How to perform two different tasks when I press close buttons of two different GUIs created by same script?

19 May 2019, 14:07

swagfag wrote:
19 May 2019, 06:13
change the second label to rGuiClose:
Thanks a lot dear swagfag... You really solved my problem... :clap: :bravo:

Thanks a lot sir... :thumbup: :salute:
I don't normally code as I don't code normally.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, NullRefEx, scriptor2016, ShatterCoder and 175 guests