This is a first attempt at GUI. The purpose is to format homework assignments consistently. It includes two input box calls (page number and problem number) which populate the GUI, and then allow extra formatting.
I would be glad to have the code critiqued, but I am really asking about the script structure.
What I am hoping for is a good explanation of how GUI scripts interact with main resident scripts. I would like to know what strategies others use so that ExitApp doesn't close down the entire program. Do people use functions? Or does everyone do what I did, which is call a non-resident script from the main script?
I have a main script with many includes, which are application specific. I am not going to post this, suffice it to say that the includes work.
In one of the includes, random_ideas.ahk, is my GUI call. It's called /ass; because it generates homework assignment structures and follows with a semicolon.
My question is: is what I do a sensible way to set up a GUI that I only need on Sundays? (It does work.) Could or should I incorporate it into the main script as a function?
Here's all of the code (first the call from random_ideas.ahk)::
Code:
::/ass;::
run,F:\my documents\AHK\gui_assignment.ahk
winwaitactive,Assignment
WinWaitClose,Assignment
sleep,500
sendinput,;{space}
return
Basically I am running the GUI as a separate program because of ExitApp.
Here's the GUI:
Code:
#SingleInstance
Gui, Add, Radio, vRgroup Checked, None
Gui, Add, Radio, , &Lesson
Gui, Add, Radio, , &Assignment
Gui, Add, Radio, , &Skills
Gui, Add, Radio, , &OB
Gui, Add, Radio, , &RB
gui, add, text,, Page:
gui, add, edit, vPage
gui, add, checkbox, vProblem, &Problem
gui, add, text, , Num
gui, add, edit, vNum
inputbox, Page2, Page?
GuiControl,, Page, %Page2%
inputbox, Num2, Problem Numbers?
if(Num2<>""){
guicontrol,,Problem,1
}
GuiControl,, Num, %Num2%
Gui, Add, Button, default, OK ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Add, Button, , Cancel ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Assignment
return ; End of auto-execute section. The script is idle until the user does something.
GuiClose:
ButtonOK:
Gui, Submit ; Save the input from the user to each control's associated variable.
var_holder = P %Page%
if(Rgroup=1){
var_holder2 = %var_holder%
}
if(Rgroup=2){
var_holder2 = Lesson %var_holder%
}
if(Rgroup=3){
var_holder2 = Assignment %var_holder%
}
if(Rgroup=4){
var_holder2 = Skills %var_holder%
}
if(Rgroup=5){
var_holder2 = OB %var_holder%
}
if(Rgroup=6){
var_holder2 = RB %var_holder%
}
if(Problem = 0){
var_holder3 = %var_holder2%
}
if(Problem = 1){
var_holder3 = %var_holder2%: %Num%
}
sendinput, %var_holder3%
ExitApp
ButtonCancel:
GuiEscape:
ExitApp