Jump to content

GUICtrlSetOnEvent Function Parameter?


Recommended Posts

I am having my first Problem with Autoit. It is really a great language.

So what is my Problem?

I have a Script which calls Usernames from a Database and displays them with a Context Menu for each User.

So, if I know click a Button in someones Menu, the Function that is called has to know which Users Contextmenu it was.

I have put

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao")

So, to know which User it was I could simply join a Parameter after the Function. Like this

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao($id)")

But this of course wont work. Is there any other simple way beside creating 50 Functions for each User?

Edited by ONeill
Link to comment
Share on other sites

I am having my first Problem with Autoit. It is really a great language.

So what is my Problem?

I have a Script which calls Usernames from a Database and displays them with a Context Menu for each User.

So, if I know click a Button in someones Menu, the Function that is called has to know which Users Contextmenu it was.

I have put

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao")

So, to know which User it was I could simply join a Parameter after the Function. Like this

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao($id)")

But this of course wont work. Is there any other simple way beside creating 50 Functions for each User?

You should be working with arrays instead of trying to create unique variable names for every instance.

:)

Edit: And what martin said, too!

:(

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I am having my first Problem with Autoit. It is really a great language.

So what is my Problem?

I have a Script which calls Usernames from a Database and displays them with a Context Menu for each User.

So, if I know click a Button in someones Menu, the Function that is called has to know which Users Contextmenu it was.

I have put

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao")

So, to know which User it was I could simply join a Parameter after the Function. Like this

Assign("context_joinaao"&$id,GUICtrlCreateMenuItem("Join AAO",eval("context_gui"&$id)),2)
GUICtrlSetOnEvent(-1,"subfunction_joinaao($id)")

But this of course wont work. Is there any other simple way beside creating 50 Functions for each User?

Apart from considering arrays, you can have all the menu items set to the same function; there is no need to have a different function for each menu item. Then in that common function you can decide what to do based on the control ID which called the function.

Within the called user function the control identifier can be retrieved with @GUI_CTRLID.

If needed the windows handle and the control handle can be retrieved with @GUI_WINHANDLE or @GUI_CTRLHANDLE.

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...