| View previous topic :: View next topic |
| Author |
Message |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Mon Nov 13, 2006 12:37 pm Post subject: Call functions dynamically |
|
|
With a close link to ma request on calling functions in SetTimer and Hotkeys I would like to make a second wish. When adding function call isn't possible for GUI gLabels or Menu Labels, it would be great if functions could be called dynamically, e.g. | Code: | func = FunctionsName
Ret := %func%(A_AHKVersion) | Maybe supported with a "IsFunction(func)" similar to IsLabel(). _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5376 Location: /b/
|
Posted: Mon Nov 13, 2006 12:43 pm Post subject: |
|
|
Chris said this is already planned. _________________
 |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Mon Nov 13, 2006 1:53 pm Post subject: |
|
|
Then maybe my request will raise its priority. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3644 Location: Belgrade
|
Posted: Mon Nov 13, 2006 1:56 pm Post subject: |
|
|
Optmistic !
 _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Mon Nov 13, 2006 2:54 pm Post subject: |
|
|
| Yes it's planned. In the meantime, there is one sneaky way to call a function dynamically: A script can register a function via OnMessage and then send a message to itself to call the function. However, I realize this is quite awkward, so it would only be useful in cases where a dynamic call is essential. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3644 Location: Belgrade
|
Posted: Mon Nov 13, 2006 3:18 pm Post subject: |
|
|
 _________________
 |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 487
|
Posted: Sun Dec 02, 2007 5:54 pm Post subject: |
|
|
Can anyone help me understand Chris's suggestion about registering a function with OnMessage and calling it by sending a message?
Is the idea that you can dynamically specify the OnMessage event and then call that event by sending the message to it? I don't fully understand how you can use this to run a particular function.
Maybe it would be too complicated until AHK has dynamic function features, but I'd like to come up with menu code which allows launching a function directly depending on the menu item clicked, without having to pre-specify the functions in the menu processing code.
For instance, a menu item in my custom menu that specifies "ThisFunction(...)" as its action; the menu processing code would attempt to run ThisFunction with the params specified, without already necessarily knowing about ThisFunction or its parameters before the call was made.
Is this feasible? _________________ -Ben
SteamLab Wiki
SteamLab Trac site
[Broken] - My industrial music |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2699 Location: Australia, Qld
|
Posted: Mon Dec 03, 2007 12:21 am Post subject: |
|
|
It is feasible.
The OnMessage method allows only two numeric parameters (wParam and lParam), so I suggest you take a look at Call 1.0, which allows any number of numeric parameters (and is probably easier to use than OnMessage.) String parameters may be passed by address, but must be translated back to strings manually by the called function. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3644 Location: Belgrade
|
Posted: Mon Dec 03, 2007 5:39 pm Post subject: |
|
|
Just use Call module _________________
 |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 487
|
Posted: Tue Dec 04, 2007 3:23 am Post subject: |
|
|
Not sure how I missed that, it's exactly what I was looking for. Thank you very much! _________________ -Ben
SteamLab Wiki
SteamLab Trac site
[Broken] - My industrial music |
|
| Back to top |
|
 |
|