Angel Posted November 3, 2004 Posted November 3, 2004 Hi,while trying to write a GUI I tried to do the following: GuiSetOnEvent($GUI_EVENT_CLOSE, "Exit")I thought that that would make my GUI simply exit when the window was closed. However nothing happened!I guess that the reason is that Exit is not really a function and what I was trying to do is to "evaluate" "Exit" when the GUI_EVENT_CLOSE was received.I understand the current limitation, but it would be great if something like this was possible. In fact it would be great if we could put any expression as the "function" argument and that the expression would simply be evaluated upon reception of the event as it would be when calling the "Eval" function.With this change for instance it would be possible to do: GuiSetOnEvent($GUI_EVENT_CLOSE, "Exit 4")That is, directly ask the function to exit giving a certain exit code.I know that I could simply create a function which would call "Exit 4" but calling Eval on the funcition string seems a pretty natural and simple syntax. Also it would avoid the need to define a funciton per gui element when using the event mode.Cheers,Angel
jpm Posted November 3, 2004 Posted November 3, 2004 Angel said: Hi,while trying to write a GUI I tried to do the following: GuiSetOnEvent($GUI_EVENT_CLOSE, "Exit")I thought that that would make my GUI simply exit when the window was closed. However nothing happened!I guess that the reason is that Exit is not really a function and what I was trying to do is to "evaluate" "Exit" when the GUI_EVENT_CLOSE was received.I understand the current limitation, but it would be great if something like this was possible. In fact it would be great if we could put any expression as the "function" argument and that the expression would simply be evaluated upon reception of the event as it would be when calling the "Eval" function.With this change for instance it would be possible to do: GuiSetOnEvent($GUI_EVENT_CLOSE, "Exit 4")That is, directly ask the function to exit giving a certain exit code.I know that I could simply create a function which would call "Exit 4" but calling Eval on the funcition string seems a pretty natural and simple syntax. Also it would avoid the need to define a funciton per gui element when using the event mode.Cheers,Angel<{POST_SNAPBACK}>exit is a function but not a user function so it cannot be called by the SetOnEvent
therks Posted November 4, 2004 Posted November 4, 2004 Yeah, create a function that calls exit. GuiSetOnEvent($GUI_EVENT_CLOSE, "ExitMe") Func ExitMe() Exit EndFunc My AutoIt Stuff | My Github
Angel Posted November 4, 2004 Author Posted November 4, 2004 Saunders said: Yeah, create a function that calls exit.GuiSetOnEvent($GUI_EVENT_CLOSE, "ExitMe") Func ExitMe() Exit EndFunc<{POST_SNAPBACK}>I know, and that is what I did. But it forces you to add lots of functions when you could do the work much more easilly if you could put any string in there and have it evaluated with "Eval".For instance, not being able to call "Exit" directly means that you always need to create a function to be able to close the window when you click on the "close" button.Angel
Valik Posted November 4, 2004 Posted November 4, 2004 See, this is why somebody invented include files. ; GUI.au3 Func OnExit() Exit EndFunc Func GuiWaitClose($hWnd) While WinExists($hWnd) Sleep(25) Wend EndFunc Now, when you write a GUI script, include that file and you can now reference the functions and use them over and over. This is a scripting language, after-all, people are allowed to write and re-use their own code.
CyberSlug Posted November 4, 2004 Posted November 4, 2004 Valik said: This is a scripting language, after-all, people are allowed to write and re-use their own code.<{POST_SNAPBACK}>True, but sometimes it's better to hold a funeral for that old code Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Valik Posted November 4, 2004 Posted November 4, 2004 CyberSlug said: True, but sometimes it's better to hold a funeral for that old code <{POST_SNAPBACK}>I've avoided that article once already today...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now