AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Call functions dynamically

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Mon Nov 13, 2006 12:37 pm    Post subject: Call functions dynamically Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5376
Location: /b/

PostPosted: Mon Nov 13, 2006 12:43 pm    Post subject: Reply with quote

Chris said this is already planned.
_________________

Back to top
View user's profile Send private message Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Mon Nov 13, 2006 1:53 pm    Post subject: Reply with quote

Then maybe my request will raise its priority.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Mon Nov 13, 2006 1:56 pm    Post subject: Reply with quote

Optmistic !

Very Happy
_________________
Back to top
View user's profile Send private message MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Mon Nov 13, 2006 2:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Mon Nov 13, 2006 3:18 pm    Post subject: Reply with quote

Shocked
_________________
Back to top
View user's profile Send private message MSN Messenger
bmcclure



Joined: 24 Nov 2007
Posts: 487

PostPosted: Sun Dec 02, 2007 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2699
Location: Australia, Qld

PostPosted: Mon Dec 03, 2007 12:21 am    Post subject: Reply with quote

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
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Mon Dec 03, 2007 5:39 pm    Post subject: Reply with quote

Just use Call module
_________________
Back to top
View user's profile Send private message MSN Messenger
bmcclure



Joined: 24 Nov 2007
Posts: 487

PostPosted: Tue Dec 04, 2007 3:23 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group