Same controls across multiple GUIs

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kiwichick
Posts: 139
Joined: 21 Jan 2014, 22:03

Same controls across multiple GUIs

23 Jul 2017, 21:54

Hi there,

I have a script with multiple, numbered GUIs. Three of the GUIs include the same three buttons - Back, Restart, and Exit - which I have manually created in each GUI and manually make any blanket changes to each GUI one-at-a-time. So I would like to know:

1) Is there a way to use a subroutine or function to create and change the buttons across all three GUIs? And can I create one set of buttons that are functional across all 3 GUIs even if a previous GUI has been destroyed?

2) The positioning of the buttons (centered across the bottom of each GUI window) is achieved using a function (defined in an #included Functions file and called separately in each GUI). I'm not overly experienced with functions but, from what I understand, I can't use one function inside another function so is it possible to achieve what I want in question 1 while still using the positioning function?

Cheers :-)
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Same controls across multiple GUIs

24 Jul 2017, 07:54

This may help you get started:

Code: Select all

GUI 1:+ToolWindow
GUI 2:+ToolWindow
GUI 3:+ToolWindow

GUI, 1:Add, Button, gButton, Button
GUI, 2:Add, Button, gButton, Button
GUI, 3:Add, Button, gButton, Button

GUI, 1:Show, w120 y100, 1
GUI, 2:Show, w120 y200, 2
GUI, 3:Show, w120 y300, 3

Return

Button:
MsgBox, You pressed the button in GUI: %A_GUI%
Return

1GUIClose:
2GUIClose:
3GUIClose:
ExitApp
Basically you can use the same label for all the same type of buttons and determine which GUI was used using the built-in A_GUI and change whatever is necessary based on that.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 242 guests