Ok, sorry it has been a couple of weeks since I have done some scripting so I didn't read it all that well.
Unfortunately you can't create the one function to the best of my knowledge except by using notifications from the win32 API. The biggest issue with this is that you will probably need to use a 3 dimensional array so that you have the handle for each window and then each element within the window (which then obviously can use a lot of memmory in large cases and would either require reading the XML for the window or hard coding each element for each window).
Personally I think this will take more code and will be less effective. The whole idea of using multiple functions is because each window has different features and hence different requirements.
What you might want to do instead is something like the following:
code:
function OnWindowEvent_CtrlClicked(PlusWnd,CntrlId){
switch(CntrlId){
case "first": callCommonFunction(PlusWnd.Handle);
case "second" : callAnotherFunction();
}
}
function OnYetAnotherWindowEvent_CtrlClicked(PlusWnd,CntrlId){
switch(CntrlId){
case "first": callCommonFunction(PlusWnd.Handle);
case "third" : callYetAnotherFunctionWhichInstAbove();
}
}
function callCommonFunction(oHandle){
Interop.Call("User32.dll", "MessageBoxW", oHandle, "Hello!", "Example Message", 0); // Either window will have this message displayed on top
}
I know this isn't exactly what you are looking for, but it is probably the best solution I can think of off of the top of my head.
Also, I can understand the OOP, but it is more complex than you need to make it. The likes of iTunes+ and NowPlaying are two scripts that use objects effectively and are much easier to read imho (it might just be those underscores that are doing it to me and the lack of spaces due to the forum). This is purely my own opinion though, I'm not saying you have to code the way I like, I was just making a recommendation. I don't think there is any reason why you should need to make things complex in such a nice and basic language