 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Sat Aug 29, 2009 11:35 am Post subject: Make g-Label Not Activate By Script |
|
|
Hi All,
Long version: I'm having trouble with some g-Labels for edit controls. I am making a color picker, so there are quite a few edit controls that must change in response to any other control changing based on user input. Because of this, each one needs a g-Label—to know when the user has made a change, and change the others accordingly—but, unfortunately, when the script changes the others, it triggers, the g-Labels again, and so on, in an infinite loop.
I need some way to determine if a thread was called by a script-generated action or by user input. Both A_GuiEvent provides no help, and AltSubmit doesn't change it... Is there any way to accomplish this?
Short version: How can I make edit controls g-Labels only fire based on user input, or at least be able to tell if they fired based upon user input rather than the script changing the control? |
|
| Back to top |
|
 |
Roland
Joined: 08 Jun 2006 Posts: 307
|
Posted: Sat Aug 29, 2009 2:30 pm Post subject: |
|
|
I could be wrong, but I don't think there is a way to determine whether the user or the script itself triggered the g-label.
As a workaround, you could temporarily turn off the g-labels of the controls you are updating, and then turn them back on afterwards. It's a bit painful to code, but it should solve your infinite loop problem.
Example:
| Code: | #NoEnv
#SingleInstance force
Gui, Add, Edit, vedit1 r1 glabel1, Enter text here.
Gui, Add, Edit, vedit2 r1 glabel2, Enter text here.
Gui, Add, Edit, vedit3 r1 glabel3, Enter text here.
Gui, Show,, g-label test
return
label1:
Gui, Submit, noHide
GuiControl, -g, edit2
GuiControl, -g, edit3
GuiControl,, edit2, % edit1
GuiControl,, edit3, % edit1
GuiControl, +glabel2, edit2
GuiControl, +glabel3, edit3
return
label2:
Gui, Submit, noHide
GuiControl, -g, edit1
GuiControl, -g, edit3
GuiControl,, edit1, % edit2
GuiControl,, edit3, % edit2
GuiControl, +glabel1, edit1
GuiControl, +glabel3, edit3
return
label3:
Gui, Submit, noHide
GuiControl, -g, edit1
GuiControl, -g, edit2
GuiControl,, edit1, % edit3
GuiControl,, edit2, % edit3
GuiControl, +glabel1, edit1
GuiControl, +glabel2, edit2
return
GuiClose:
exitApp |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Aug 29, 2009 6:07 pm Post subject: |
|
|
| Krogdor wrote: | | each one needs a g-Label—to know when the user has made a change, and change the others accordingly—but, unfortunately, when the script changes the others, it triggers, the g-Labels again, and so on, in an infinite loop. |
Every g-Label could check the Control-Focus with GuiControlGet, Var, Focus and act accordingly.
| Code: | #SingleInstance, Force
Gui, Add, Text, x5 w50, Red
Gui, Add, Edit, x+5 vE1 w50 h20 gEdit1, 0
Gui, Add, Text, x5 w50, Green
Gui, Add, Edit, x+5 vE2 w50 h20 gEdit2, 0
Gui, Add, Text, x5 w50, Blue
Gui, Add, Edit, x+5 vE3 w50 h20 gEdit3, 0
Gui, Add, Text, x5 y+15 w50, Hue
Gui, Add, Edit, x+5 vE4 w50 h20 gEdit4, 0
Gui, Add, Text, x5 w50, Sat
Gui, Add, Edit, x+5 vE5 w50 h20 gEdit5, 0
Gui, Add, Text, x5 w50, Lum
Gui, Add, Edit, x+5 vE6 w50 h20 gEdit6, 0
Gui, Show
Return
Edit1:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E2, 2
Return
Edit2:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E3, 3
Return
Edit3:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E4, 4
Return
Edit4:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E5, 5
Return
Edit5:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E6, 6
Return
Edit6:
GuiControlGet, EF, Focus
IfNotEqual, EF, %A_ThisLabel%, Return
GuiControl,, E1, 1
Return
GuiClose:
ExitApp
|
Ad: Crazy Scripting : ColorMixer - Lite ( RGB-HSL ) |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Sat Aug 29, 2009 7:46 pm Post subject: |
|
|
Alright, I thought of something similar to each of those, or maybe some combination, but thought there might be an easier way to accomplish this.
Thanks for your help, both of you.
@SKAN: Yes, I've seen (both?) of your color pickers But I didn't really like either, and kind of felt like trying to make my own instead. |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|