TempFuncRef := _Main_Script_.Test
Hotkey, F12, % TempFuncRef
Code: Select all
_Main_Script_.Gui() ;execute "Gui()" function from "_Main_Script_" class\object
return
F11:: ;_______ F11 hotkey _______
_Main_Script_.Test() ;execute "Test()" function from "_Main_Script_" class\object
return
Class _Main_Script_{
Gui(_Options_ := "") ;____________ Gui(Function) _____________
{
static
if (_Options_[1] != "")
{
_Options_ := _Options_[1]
_Options_ := %_Options_%
return, _Options_
}
x := "xxx gui xxx"
gui, add, button, vBttnGMP, Test (or Press F11 or F12)
;_____
TempFuncRef := _Main_Script_.Test ;the reference of "Test()" function from "_Main_Script_" class\object is stored in "TempFuncRef" variable
GuiControl, +g, BttnGMP, % TempFuncRef ;Unfortunately, "% _Main_Script_.Test" can't be used here directly!
Hotkey, F12, % TempFuncRef ;does not work! (shouldn't it work?)
;_____
gui, show, w300 h200
return
guiclose: ;__________ gui close __________
exitapp
return
}
Test() ;_________ Test(Function) ___________
{
gui, destroy
x := "xxx Test xxx"
msgbox, % ""
. "Test" "`r`n`"
. "`r`n"
. "x from Test() = " x "`r`n"
. "`r`n"
. "x from Gui() = " _Main_Script_.Gui(["x"]) "`r`n" ;get "x" var value from "Gui()" function that belongs to "_Main_Script_" class\object
. "`r`n"
. "press ok to continue!"
_Main_Script_.Gui() ;execute "Gui()" function from "_Main_Script_" class\object
}
}