When you use an if
statement without curly brackets, only the following line is read by the if statement.
That means that when you do this:
If Open = 1
Run "X:\SSC_HR\SENS\Bedrijfsbureau"
Return
...the program ends. The if statement does the run command and the return
gets processed no matter what.
So, try this, instead, if you want multiple lines:
If(Open = 1){
Run "X:\SSC_HR\SENS\Bedrijfsbureau"
Return
}
Also, nothing will happen anyway! First, when you check the box, you have no sub to handle the checkbox. In other words, when you click the checkbox, nothing is supposed to happen. So, I suppose that you only want things to happen when you push the "Go" button.
That's great, but your go button does two things: it grabs the value of the checkbox, then it exits the GUI ----> THIS IS WHY YOUR PROGRAM DOESN'T WORK.
You want to do this, instead:
Gui, Add, Checkbox, vOpen, Open Bedrijfsbureau
Gui, Add, Checkbox, vOpen2, Open
Gui, Add, Button, Default gButtonGo, Go
Gui, Show, w500 h300, Products
Return
ButtonGo:
;fetch the value of the checkbox variables
Gui, Submit
If Open = 1
Run "X:\SSC_HR\SENS\Bedrijfsbureau"
If Open2 = 1
Run "X:\SSC_HR\SENS\Bedrijfsbureau\Dimensioneren"
;Now, if you want the gui to close after the actions are complete, then uncomment the next line - if you want the gui to remain, then don't uncomment it.
;Gui, Destroy
RETURN
GUIClose:
Gui, Destroy
Finally, in this scenario, you can execute either one or both of the checkbox commands. If you only want one or the other, you should use radio buttons instead.
For a hotkey to run the primary function:
#x::
gosub, ButtonGo
return
If you want the hotkey to open the GUI, then you need to wrap the GUI in a gosub and alter the hotkey's command.