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 in HotKey, SetTimer

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



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

PostPosted: Mon Nov 13, 2006 12:24 pm    Post subject: call functions in HotKey, SetTimer Reply with quote

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


Joined: 02 Mar 2004
Posts: 10716

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

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



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Sun Dec 02, 2007 9:20 pm    Post subject: Reply with quote

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



Joined: 27 Mar 2008
Posts: 649

PostPosted: Thu May 22, 2008 4:15 am    Post subject: Reply with quote

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. Wink Very Happy
_________________
Scripts - License
Back to top
View user's profile Send private message
BeachKlas



Joined: 10 Apr 2010
Posts: 8

PostPosted: Sat Apr 10, 2010 7:54 pm    Post subject: Reply with quote

I'd like this too.
Back to top
View user's profile Send private message
Display posts from previous:   
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