Sign in to follow this  
Followers 0
crislivinitup

Create GUIctrlsetonevent with parameters in the function call

4 posts in this topic

Hey guys,

My problem is very simple. I have a lot of buttons and guictrls in my script. It would be nice if there was a syntax where a few buttons could call the same function but with a different result. It would save a lot of space and be much more efficient for me, especially when I can reuse code. I'm not sure if there is a way to call a function with guictrlsetonevent(-1,"myfunc") with parameters like, guictrlsetonevent(-1,"myfunc[2]") etc. It would be a very nice feature to include if it doesn't already exist. Is there a way to solve this problem?

Share this post


Link to post
Share on other sites

Yes. Certainly this can be done. You need to investigate some of the autoit macros - specifically @GUI_CTRLID and @GUI_CTRLHANDLE

When you a function is triggered via an onevent. These macros can be used to provide details on what triggered the event.

Share this post


Link to post
Share on other sites

Yes. Certainly this can be done. You need to investigate some of the autoit macros - specifically @GUI_CTRLID and @GUI_CTRLHANDLE

Thank you very much for your information. Wow, this is very good news. Sadly, I've already put so much work into making seperate functions, there will be a lot of re-programming ahead of me. On, the plus side you gave me the answer I've been looking for :idea:. I only wish I knew sooner.

Share this post


Link to post
Share on other sites

Usually those 2 macros, @GUI_CTRLID and @GUI_CTRLHANDLE, are all you need, but sometimes it is useful to have parameters in functions set by events. This it easier in my opinion when controls are created dynamically. Control events, gui events and Hotkeys call all have parameters using the SetOnEvent UDF which has a link in my signature.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0