Page 1 of 1

If Else in CheckBox and DropDownList

Posted: 04 Jan 2017, 14:23
by Rami
Hi,

let's say I have this simple Gui, with button "Dir" that will run the command: Dir

Code: Select all

Gui, Add, checkbox, vA, A
Gui, Add, Checkbox, vB, B
Gui, Add, Checkbox, vC, C
Gui, Add, Checkbox, vD, D
Gui, Add, DropDownList, ,Pause||Dont Pause|Wide
Gui,Add,Button, gDir, Dir
Gui, Show, center
Return

Dir:
Gui, Submit, NoHide
Run, %ComSpec% /k Dir ;here goes as checked above
return                             
But command "Dir" has a lot of parameters (i.e: dir /s /a /b ... etc.)
I need the command:
if Pause is choose

Code: Select all

Dir /p
if Pause is choose and (B, D) are checked.

Code: Select all

Dir /P /b /d
etc ...

So the command is what we chose to add to it after word :"Dir"

Is there any easier way before I go through hundreds of (If, Then, Run) ??

Any suggestion is appreciated

Re: If Else in CheckBox and DropDownList  Topic is solved

Posted: 04 Jan 2017, 14:45
by iPhilip
Would this do it?

Code: Select all

Gui, Add, checkbox, vA, A
Gui, Add, Checkbox, vB, B
Gui, Add, Checkbox, vC, C
Gui, Add, Checkbox, vD, D
Gui, Add, DropDownList, vP,Pause||Dont Pause|Wide
Gui,Add,Button, gDir, Dir
Gui, Show, center
Return

Dir:
Gui, Submit, NoHide
a := A ? "/a" : ""
b := B ? "/b" : ""
c := C ? "/c" : ""
d := D ? "/d" : ""
p := P = "Pause" ? "/p" : ""
Run, %ComSpec% /k Dir %a% %b% %c% %d% %p% ;here goes as checked above
return                             

Re: If Else in CheckBox and DropDownList

Posted: 04 Jan 2017, 14:48
by evilC
Gui, Submit, NoHide will pull tbe values of the GuiControls and populate the associated variables.
So given Gui, Add, checkbox, vA, A, then the variable A will hold 1 if Checkbox A is checked, else 0

Re: If Else in CheckBox and DropDownList

Posted: 04 Jan 2017, 15:11
by Rami
evilC,
Thank you.

iPhilip,
Thank you , i think that is what i'm looking for ...
I will try that in few...