How to work with text variables from a DDL Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
redsonja
Posts: 6
Joined: 24 Nov 2020, 06:13

How to work with text variables from a DDL

Post by redsonja » 12 Jan 2021, 09:57

Hello friends. Beginner here. How can I get my if-function to work? I know that variables have to be numbers but there has to be a way around that.
I tried messing with "GuiControl, +AltSubmit" but quite frankly didn't really get what I was doing there...

Thanks in advance

Code: Select all

#Persistent

Gui, Add, DropDownList, vColorChoice, Black|White|Red|Green|Blue|
Gui, Add, Button, Default w80, OK
Gui, Add, Button, w80, Cancel
Gui, Show
return

GuiClose:
ExitApp

ButtonCancel:
ExitApp

ButtonOK:
Gui, Submit 
Gui, Hide

If (ColorChoice = Blue)
{
MsgBox, Blue
}

If (ColorChoice = Red)
{
MsgBox, Red
}


ExitApp

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

Re: How to work with text variables from a DDL  Topic is solved

Post by Hellbent » 12 Jan 2021, 10:04

2 things.

1. Add quotes around the strings in your if statements
2. You should have a return at the end of you "OK" subroutine. (unless you really do want to exit after it is done)

Code: Select all


#Persistent

Gui, Add, DropDownList, vColorChoice, Black|White|Red|Green|Blue|
Gui, Add, Button, Default w80, OK
Gui, Add, Button, w80, Cancel
Gui, Show
return

GuiClose:
ExitApp

ButtonCancel:
ExitApp

ButtonOK:
Gui, Submit 
Gui, Hide

If (ColorChoice = "Blue")
{
MsgBox, Blue
}

If (ColorChoice = "Red")
{
MsgBox, Red
}
return

ExitApp

User avatar
redsonja
Posts: 6
Joined: 24 Nov 2020, 06:13

Re: How to work with text variables from a DDL

Post by redsonja » 12 Jan 2021, 10:20

Thank you! I could swear I tried that one before, don't know what went wrong... :salute:
Hellbent wrote:
12 Jan 2021, 10:04
2 things.

1. Add quotes around the strings in your if statements
2. You should have a return at the end of you "OK" subroutine. (unless you really do want to exit after it is done)

Code: Select all


#Persistent

Gui, Add, DropDownList, vColorChoice, Black|White|Red|Green|Blue|
Gui, Add, Button, Default w80, OK
Gui, Add, Button, w80, Cancel
Gui, Show
return

GuiClose:
ExitApp

ButtonCancel:
ExitApp

ButtonOK:
Gui, Submit 
Gui, Hide

If (ColorChoice = "Blue")
{
MsgBox, Blue
}

If (ColorChoice = "Red")
{
MsgBox, Red
}
return

ExitApp

Post Reply

Return to “Ask For Help”