Code: Select all
myGui:=Gui()
myGui.addEdit("vInput")
myGui.addButton(,"Submit").onEvent("Click",(*)=> output:=myGui.submit())
myGui.show()
winwaitclose myGui
msgbox output.Input
Code: Select all
myGui:=Gui()
myGui.addEdit("vInput")
myGui.addButton(,"Submit").onEvent("Click",(*)=> output:=myGui.submit())
myGui.show()
winwaitclose myGui
msgbox output.Input
Code: Select all
myGui:=Gui()
myGui.addEdit("vInput")
myGui.addButton(,"Submit").onEvent("Click",(*)=> (myGui.output := myGui.submit()))
myGui.show()
winwaitclose myGui
msgbox myGui.output.Input
Code: Select all
myGui:=Gui()
myGui.addEdit("vInput")
myGui.addButton(,"Submit").onEvent("Click", submit_handler)
myGui.show()
submit_handler(ctrl, *) {
output := ctrl.gui.submit()
msgbox(output.Input)
}
I want to use the variable outsite the callback functionkczx3 wrote: ↑03 Mar 2023, 10:44There are numerous ways to do this. One would be:
Code: Select all
myGui:=Gui() myGui.addEdit("vInput") myGui.addButton(,"Submit").onEvent("Click", submit_handler) myGui.show() submit_handler(ctrl, *) { output := ctrl.gui.submit() msgbox(output.Input) }
Code: Select all
myGui:=Gui()
edt1 := myGui.addEdit("vInput")
myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.submit())
myGui.show
winwaitclose myGui
msgbox edt1.text
Moreover, you don't need submit() in this case.flyingDman wrote: ↑You do not even need vInput.
Code: Select all
myGui:=Gui()
editObj := myGui.addEdit()
myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide())
myGui.show()
winwaitclose myGui
msgbox editObj.Text
The problem with this approach is that I can't close the gui to stop the script, it will always get the control text.teadrinker wrote: ↑03 Mar 2023, 11:16Moreover, you don't need submit() in this case.flyingDman wrote: ↑You do not even need vInput.Code: Select all
myGui:=Gui() editObj := myGui.addEdit() myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide()) myGui.show() winwaitclose myGui msgbox editObj.Text
Why not:yousef_badr23 wrote: ↑The problem with this approach is that I can't close the gui to stop the script, it will always get the control text.
Code: Select all
myGui:=Gui()
myGui.onEvent('Close', (*) => ExitApp())
editObj := myGui.addEdit()
myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide())
myGui.show()
winwaitclose myGui
msgbox editObj.Text
Better! Is there a way to use Exit instead of ExitApp? I understand that having a separate thread for the event would make this difficult.teadrinker wrote: ↑03 Mar 2023, 12:51Why not:yousef_badr23 wrote: ↑The problem with this approach is that I can't close the gui to stop the script, it will always get the control text.Code: Select all
myGui:=Gui() myGui.onEvent('Close', (*) => ExitApp()) editObj := myGui.addEdit() myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide()) myGui.show() winwaitclose myGui msgbox editObj.Text
Code: Select all
myGui:=Gui()
myGui.onEvent('Close', (*) => myGui.Destroy())
editObj := myGui.addEdit()
myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide())
myGui.show()
winwaitclose myGui
if !WinExist()
return
msgbox editObj.Text
Thanks alot!!!teadrinker wrote: ↑03 Mar 2023, 13:42Maybe like this:Code: Select all
myGui:=Gui() myGui.onEvent('Close', (*) => myGui.Destroy()) editObj := myGui.addEdit() myGui.addButton(,"Submit").onEvent("Click",(*)=> myGui.Hide()) myGui.show() winwaitclose myGui if !WinExist() return msgbox editObj.Text
Users browsing this forum: DavidP, FanaticGuru, mikeyww, TomDonovan and 107 guests