User Input for GUI Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ben the Coder

User Input for GUI

Post by Ben the Coder » 16 May 2022, 16:05

I have a GUI, and I need my script to do different things depending on the button pressed. I've looked through all the different sections in the AutoHotkey user guide, like:
https://www.autohotkey.com/docs/commands/Gui.htm#Events
And I've tried to save the user input as a variable and then depending on the variable contents, end the program or continue, but it doesn't work.
I can't seem to figure this out!
Below is my code:

Code: Select all

Gui, -Caption +LastFound -SysMenu +ToolWindow -DPIScale
Gui, Font, [, s15, Veranda]
Gui, Add, Text,, Welcome to SimpleCalc setup.
Gui, Add, Text,, This wizard will guide you through installing the software SimpleCalc.
Gui, Add, Text,, Click "next>>" to continue, and "abort" to abort the process.
Loop, Parse,% "ABORT,NEXT>>", CSV
	Gui, Add, Button, x+ y20 gOperator,% A_LoopField
Gui, Show
Return
INTRO := StrReplace(A_GuiControl, "&&", "&")
IfEqual, INTRO ,[, ABORT]
	ExitApp
IfEqual, INTRO ,[, NEXT>>]
	return
Gui, Destroy
Can anyone help me with this?
Thanks!

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

Re: User Input for GUI

Post by mikeyww » 16 May 2022, 16:39

Code: Select all

Gui, Font, s10
Gui, Add, Text,, Welcome to SimpleCalc setup.
Gui, Add, Text,, This wizard will guide you through installing the software SimpleCalc.
Gui, Add, Text,, Click "next>>" to continue, and "abort" to abort the process.
Loop, Parse, % "ABORT,NEXT>>", CSV
 Gui, Add, Button, y20 gOperator, % A_LoopField
Gui, Show
Return

Operator:
Switch A_GuiControl {
 Case "ABORT" : MsgBox, 1
 Case "NEXT>>": MsgBox, 2
}
Return

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

Re: User Input for GUI

Post by BoBo » 16 May 2022, 16:50

Code: Select all

Gui, -Caption +LastFound -SysMenu +ToolWindow -DPIScale
Gui, Font, [, s15, Veranda]
Gui, Add, Text,, Welcome to SimpleCalc setup.
Gui, Add, Text,, This wizard will guide you through installing the software SimpleCalc.
Gui, Add, Text,, Click "next>>" to continue, and "abort" to abort the process.
Gui, Add, Button, x10 y20 gExit,% "ABORT"
Gui, Add, Button, x60 yp  gNext,% "NEXT>>"
Gui, Show
Return

Exit:
	ExitApp
Next:
    Return
Not tested.

User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: User Input for GUI

Post by boiler » 16 May 2022, 22:44

@Ben G - You keep putting square brackets [ ] around optional parameters of commands. I've seen you do it in at least a couple different threads. The bracket are used in the documentation just to indicate that the parameter is optional. The brackets themselves do not go in your code.

Ben the Coder

Re: User Input for GUI

Post by Ben the Coder » 17 May 2022, 09:28

Really? I didn't know that! I look in the user guide often, and they sometimes have square brackets around certain sections. Thanks so much! This forum is so amazing, and the people in it are so helpful! :-D

User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: User Input for GUI  Topic is solved

Post by boiler » 17 May 2022, 11:08

Ben G wrote: Really? I didn't know that! I look in the user guide often, and they sometimes have square brackets around certain sections.
Yes. See Documentaiton Conventions.

Post Reply

Return to “Ask for Help (v1)”