AutoHotkey Community

It is currently May 27th, 2012, 9:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 13th, 2006, 1:24 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 3:48 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2007, 10:20 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 5:15 am 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
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. ;) :D

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2010, 8:54 pm 
Offline

Joined: April 10th, 2010, 12:36 pm
Posts: 8
I'd like this too.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group