Code: Select all
#q::EnterFormula()
EnterFormula(){
Loop
{
FormulaWindow(FormulaEntered, CancelCode)
If(CancelCode = 1){
FormulaEntered = 0
break
}
Else{
DialogBoxTwo(FormulaEntered, DialogChange)
if (DialogChange = 2){
continue
}
Else{
break
}
}
}
MsgBox %FormulaEntered%
}
DialogBoxTwo(ByRef FormulaEntered, ByRef NeedChange){
Gui, +LastFound
GuiHWND := WinExist()
Gui, Add, Button, x22 y69 w110 h40 Default, Continue
Gui, Add, Text, x62 y19 w190 h20 , Equation Entered:
Gui, Add, Text, x122 y39 w40 h20 , %FormulaEntered%
Gui, Add, Button, x152 y69 w110 h40 , Change
; Generated using SmartGUI Creator 4.0
Gui, Show, x612 y377 h135 w290, Confirm
WinWaitClose, ahk_id %GuiHWND% ;--waiting for gui to close
return ;--returning value
ButtonContinue:
NeedChange = 1
Gui, Destroy ; Destroy the GUI to get it out of the way1
return
1GuiEscape:
FormulaEntered := "You Escaped 1"
NeedChange = 1
Gui, Destroy ; Destroy the GUI to get it out of the way1
return
ButtonChange: ; Execute the following actions when the button from the GUI Change is pressed
NeedChange = 2
Gui, Destroy ; Destroy the GUI to get it out of the way
return
}
FormulaWindow(ByRef UserInput, ByRef ToCancel){
Global FUserInput
Gui, +LastFound
GuiHWND2 := WinExist()
Gui, Add, Button, x42 y129 w110 h30 Default, OK
Gui, Add, Button, x162 y129 w110 h30 , Cancel
Gui, Add, Button, x282 y129 w110 h30 , Clear
; Note that v is the convention used to denote the variable below but the actual variable saved is without the v as just UserInput
Gui, Add, Edit, x42 y89 w350 h20 vFUserInput,
Gui, Add, Text, x14 y92 w22 h16 , y =
Gui, Add, Text, x12 y9 w290 h20 , Enter an equation for Y as a function of X
Gui, Add, Text, x12 y29 w150 h20 , eg. x + 1
Gui, Add, Text, x12 y49 w150 h20 , eg. 2*x + 3
; Generated using SmartGUI Creator 4.0
Gui, Show, x530 y255 h184 w411, Enter Equation
GuiControl, Focus, FUserInput
WinWaitClose, ahk_id %GuiHWND2% ;--waiting for gui to close
return
ButtonOK: ; Execute the following actions when the button from the GUI OK is pressed
Gui, Submit ; Save all the information in the GUI (The variables)
UserInput = %FUserInput%
ToCancel = 2
Gui, Destroy ; Destroy the GUI to get it out of the way
Return
2GuiEscape:
UserInput := "You Escaped 2"
ToCancel = 1
Gui, Destroy ; Destroy the GUI to get it out of the way
return
ButtonCancel:
UserInput = 0
ToCancel = 1
Gui, Destroy ; Destroy the GUI to get it out of the way
Return
ButtonClear:
GuiControl, ,FUserInput
GuiControl, Focus, FUserInput
Return
}
`::exitapp