AutoHotkey Community

It is currently May 27th, 2012, 1:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: November 18th, 2011, 11:35 pm 
I always wonder about the need of lines like, Gui, Submit, NoHide and GuiControlGet, out,, AssociatedVar when I retrieve values from Gui controls. Would it be possible to add an option like AutoSubmit so that the associated value automatically gets updated and we don't need the commands to retrieve it?

Something like this,
Code:
Gui, Margin, 20,20
Gui, Add, DDL, vActionForm gActionForm AutoSubmit, aaa||bbb|ccc
Gui, Show
return

ActionForm:
   msgbox % ActionForm   ;returns the selected value
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2011, 11:42 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Performance would take quite the hit :/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2011, 11:46 pm 
That's why it's an option.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 12:28 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Every time you acessed any var's contents, AHK would have to check if it was one associated with a control. Similar to not using #NoEnv, it would still slow down all scripts.

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 12:34 am 
Same as gLabel.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 2:26 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Anonymous wrote:
Same as gLabel.
no... gLabel has nothing to do with every variable in a script :roll:

gLabel AFAIK works like OnMessage


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 2:38 am 
Then it won't be a problem if it is implemented like OnMessage.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 2:41 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
it can't be :roll: there are no messages sent when specific variables are accessed :arrow: every variable would have to be checked each time


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 2:45 am 
Wrong. The variable only needs to be accessed when the control is accessed.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 2:55 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
I see. This can be implemented with a g-label, in that case. It is exactly the same as your request except for 2 things:
  1. The AutoSubmit option has a 'g' in front of it
  2. It requires 3 whole lines (oh noes) added to the script

Code:
Gui, Add, Edit, vMyEdit1 gAutoSubmit
Gui, Add, Edit, vMyEdit2 gAutoSubmit
Gui, Add, Edit, vMyEdit3 gAutoSubmit
Gui Show

F1::
F2::
F3::
 N := SubStr(A_ThisHotkey, 2)
 MsgBox % MyEdit%N%
return

AutoSubmit:
 GuiControlGet, %A_GuiControl%,, %A_GuiControl%
return
You could even put that label in a separate file and #Include it at the bottom of your script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 3:02 am 
That way the user cannot use gLabel normally. That's why the suggestion would be useful.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 3:41 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
The user can simply call GuiControlGet from their g-label to update the variable. An AutoSubmit option seems like it might be convenient, but it probably does not have sufficient net benefit.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2011, 8:28 am 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
I like the idea. Some gui-controls like DateTime, MonthCal, Slider, Tab2, UpDown, already process a built-in "AutoSubmit" when launching the g-label, so why shouldn't the others have it as an option?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2011, 6:18 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Here's as close as you will come to the suggested functionality:
Code:
Gui, Add, Edit, vEdit1 gAutoSubmit
Gui, Add, Edit, vEdit2 gAutoSubmit
Gui, Add, Edit, vEdit3 gAutoSubmit
Gui Show
Loop 3
 Hotkey F%A_Index%, Disp
return

Disp:
 n := SubStr(A_ThisHotkey, 2)
 MsgBox % Edit%N%
return

Edit1: ; called when the user changes the contents of Edit1
 ToolTip % Edit1
return

AutoSubmit:
 GuiControlGet, %A_GuiControl%
 If IsLabel(A_GuiControl)
   goto % A_GuiControl
return
Specify gAutoSubmit for the control's variable to update automatically. If a label with the same name as the control's variable is present, it will be launched immediately after the control's variable is updated. Of course, you could change the last few lines to add a naming convention such as variableName_Label: as opposed to variableName:

This has the same effect as calling GuiControlGet %A_GuiControl% in each of the gLabels; however it will save some lines of code if you have many 'AutoSubmit' controls.

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 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