Christopher Blue Posted October 29, 2006 Share Posted October 29, 2006 (edited) Is there a way to obtain the name of the current function? Being able to do so would simplify many parts of my scripts. For instance, for HotKeySet I would be able to make a generic block of code to release and reacquire a hotkey rather than having to type a new function name for each one. Edited October 29, 2006 by Christopher Blue Link to comment Share on other sites More sharing options...
xcal Posted October 29, 2006 Share Posted October 29, 2006 I read it about 5 times and didn't get it. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Christopher Blue Posted October 29, 2006 Author Share Posted October 29, 2006 (edited) I read it about 5 times and didn't get it. Instead of this: Func HotKeyFunc() Dim $c = @HotKeyPressed If (HotKeyShouldBePassedOn()) Then HotKeySet($c) Send($c) HotKeySet($c, "HotKeyFunc") Return EndIf EndFunc I could write this: Func HotKeyFunc() Dim $c = @HotKeyPressed If (HotKeyShouldBePassedOn()) Then HotKeySet($c) Send($c) HotKeySet($c, CurrentFunctionName()) Return EndIf EndFunc It is a small difference but it would be one less place for me to make a typo or even worse, accidently put in the wrong function name. Edited October 29, 2006 by Christopher Blue Link to comment Share on other sites More sharing options...
xcal Posted October 29, 2006 Share Posted October 29, 2006 Still not quite getting the big picture here, but, couldn't you just have your functions set a $var and pass it as an argument through your HotKeyFunc()? Func HotKeyFunc($func_var) Dim $c = @HotKeyPressed If (HotKeyShouldBePassedOn()) Then HotKeySet($c) Send($c) HotKeySet($c, $func_var) Return EndIf EndFunc How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Christopher Blue Posted October 29, 2006 Author Share Posted October 29, 2006 HotKey'd functions cannot take arguments IIRC. Link to comment Share on other sites More sharing options...
xcal Posted October 29, 2006 Share Posted October 29, 2006 Use with ctrl+c... $func = 'func1' HotKeySet('^c', $func) HotKeySet('{escape}', 'quit') Func func1($func) $key = @HotKeyPressed $func = 'func2' HotKeySet($key, $func) MsgBox(0, '', 'func 1') EndFunc Func func2($func) $key = @HotKeyPressed $func = 'func1' HotKeySet($key, $func) MsgBox(0, '', 'func 2') EndFunc Func quit() Exit EndFunc While 1 Sleep(100) WEnd How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now