| View previous topic :: View next topic |
| Author |
Message |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Mon Nov 13, 2006 12:24 pm Post subject: call functions in HotKey, SetTimer |
|
|
Hi,
I want to use functions more frequently in my code to encapsulate the code from the rest. When doing so I have to create a workaround for the Hotkey and SetTimer command (and maybe others), since they only allow to specify a label.
Is it possible to extend the commands to accept functions?
Maybe also for the GUI gLabel or Menu Label? Or rarely used commands like OnExit, GroupAdd?
Current workaround: | Code: | Hotkey, #l, hotkeysub
SetTimer, settimersub
Return
hotkeysub:
Hotkeyfunc(A_Gui)
Return
Hotkeyfunc(ID){
;magic
return
}
settimersub:
settimerfunc(A_Gui)
Return
settimerfunc(ID){
;magic
return
}
| If extended it would be | Code: | Hotkey, #l, Hotkeyfunc(A_Gui)
SetTimer, settimerfunc(A_Gui)
Return
Hotkeyfunc(ID){
;magic
return
}
settimerfunc(ID){
;magic
return
}
| It would result in cleaner and shorter code, and would make functions more appealing. I used mainly subroutines-only in the past, because I was lazy to do the workaround. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Mon Nov 13, 2006 2:48 pm Post subject: |
|
|
This has been suggested before; but the cost/benefit seems unfavorable compared to other features (such as #v2 and menu enhancements).
But thanks for the syntax ideas. I've made a note of them for when the time comes to work on it. |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Sun Dec 02, 2007 9:20 pm Post subject: |
|
|
| I would wish this also. In my big scripts with GUIs and a lot of lines, I try to encapsulate some of the code by doing the most in functions. Often it would easier (especially in GUI) if I could call the function directly, instead of creating workarounds like toralf described. |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 649
|
Posted: Thu May 22, 2008 4:15 am Post subject: |
|
|
I would very much appreciate and use this too. As an (extreme) example, I have a script with over 400 lines of workaround code that would magically disappear if hotkeys supported functions.  _________________ Scripts - License |
|
| Back to top |
|
 |
BeachKlas
Joined: 10 Apr 2010 Posts: 8
|
Posted: Sat Apr 10, 2010 7:54 pm Post subject: |
|
|
| I'd like this too. |
|
| Back to top |
|
 |
|