 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Dec 30, 2009 7:40 pm Post subject: Changing the value of an edit control which is taken over |
|
|
I want to change the value in the edit field of Wizard Master Control Program via AHK. For example to change the value of Edit49 I tried
| Code: | SetTitleMatchMode, 2
WinActivate, - + ? x
; get value of Edit49 field and display it
ControlGetText, OutputVar, Edit49, - + ? x
MsgBox, Edit49 value is %OutputVar%
Sleep, 300
; set value of Edit49 field, does not work yet
SetControlDelay -1
ControlClick, Edit49, - + ? x,, LEFT, 2
Sleep, 300
ControlSetText, Edit49, 10, - + ? x
| without any success yet. It changes the value, but the new value is NOT "taken" by the software, meaning it will still use the old value for playback.
What would be the most reliable way to change Edit49 to another value which DOES also change the playback to the new value? Thanks in advance. My ultimate goal is to control the entire Wizard Master Control Program GUI interface via AHK using only the pc keyboard, without any mouse use, if possible. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Dec 30, 2009 8:47 pm Post subject: |
|
|
ControlSetText typically (in my experience) does not cause any field-specific events to fire; IOW, if there is an "onchange" event that would normally fire when you manually type new information into that field, ControlSetText will usually bypass that event. So the program may not recognize the data in that field has been changed and is instead referencing the last entered data. What I do to get around that is throw in a quick key command using ControlSend to shift the cursor in the Edit field and trigger the event, like this:
| Code: | ControlSetText, Edit49, 10, - + ? x
ControlSend, Edit49, {SHIFTDOWN}{END}{SHIFTUP}{RIGHT} |
Try that and see if it's any help. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Dec 30, 2009 9:16 pm Post subject: |
|
|
| I tried, it does not help. I am interested actually in the best way how to deal in such situations in AHK. Thanks sinkfaze for your efforts. |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 12:54 am Post subject: |
|
|
I am using below code e.g. to increase the pitch for 1, which works, but having a more direct and faster method would be better:
| Code: | CurrentStep := "Edit49"
SleepTime = 200
Add1(CurrentStep)
{
ControlGetText, ValueEdit , %CurrentStep%, - + ÷ x
NewValueEdit := ValueEdit + 1
ControlClick, %CurrentStep%, - + ÷ x,,L,2,NA
Send, {End}
Sleep, %SleepTime%
Send, +{Home}
Sleep, %SleepTime%
Clipboard = %NewValueEdit%
ClipWait
Send, ^v
return
}
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 17, 2010 4:19 am Post subject: |
|
|
This might be a little confusing, but here are a few alternate ways to try...you need to comment/uncomment lines to test different ways...
| Code: | ;//Ctrl:="Edit49"
;//Ctrl:="Edit3"
;//SleepTime = 200
;//Gui, -Caption
Gui, Margin, 6, 6
Gui, Add, Edit, w119 vEdit1 gEditChanged, 0
Gui, Add, Edit, w119 vEdit2 gEditChanged, 0
Gui, Add, Edit, w119 vEdit3 gEditChanged, 0
Gui, Show
return
F9::Add1(Ctrl)
EditChanged:
iec++
GuiControlGet, value, , %A_GuiControl%
Tooltip, %iec%: EditChanged(%value%), 0, 157, 4
return
Add1(p_ctrl="") {
Global
ControlGetFocus, ctrlfocus, a
if (p_ctrl="") {
p_ctrl:=ctrlfocus
}
Tooltip, %A_ThisFunc%: start, 0, 119, 2
;//ControlGetText, OutputVar[, Control , WinTitle, WinText, ExcludeTitle, ExcludeText]
;//ControlGetText , ValueEdit , %p_ctrl%, - + ÷ x
ControlGetText , ValueEdit , %p_ctrl%, a
NewValueEdit:=ValueEdit+1
if (NewValueEdit="") {
NewValueEdit:=0
}
Tooltip, %A_ThisFunc%: %p_ctrl%(%ValueEdit%) -> (%NewValueEdit%), 0, 138, 3
;// Works for AutoHotkey Gui...
;// Set New Value: ControlSetText...
;//ControlSetText, %p_ctrl%, %NewValueEdit%, a
;// Clear control: ControlSetText...
;//ControlSetText, %p_ctrl%, , a
;// Clear control: Send Keys: ControlSend...
;//ControlSend[, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlSend, %p_ctrl%, {Home}+{End}, a
;// Clear control: Send Keys: Send...
;//ControlFocus, %p_ctrl%, a
;//Send, {Home}+{End}
;//ControlFocus, %ctrlfocus%, a
;// Set New Value: Control, EditPaste...
;//Control, Cmd[, Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
Control , EditPaste, %NewValueEdit%, %p_ctrl%, a
Tooltip, %A_ThisFunc%: end, 0, 119, 2
return
} |
...I cannot test with that program, but they all work on an AutoHotkey GUI...plz tell me if they work in that program... |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 11:19 am Post subject: |
|
|
Thanks Guest, I tried the shorter code below, which works great.
| Code: | Add1(CurrentStep)
{
ControlGetText, ValueEdit , %CurrentStep%, - + ÷ x
NewValueEdit := ValueEdit + 1
ControlClick, %CurrentStep%, - + ÷ x,,L,2,NA
ControlSend, %CurrentStep%, {Home}+{End}, a
Control, EditPaste, %NewValueEdit%, %CurrentStep%, a
return
} |
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 17, 2010 11:28 am Post subject: |
|
|
You need the ControlClick? I removed it, cuz in my tests, it added nothing (however, for your program, I understand if it really does something/help)...
Did you try any of the other variations? Like "ControlSetText" to clear the edit, then follow up with the "Control, EditPaste"?...I know ControlSetText, by itself, doesn't allow the program to "see" the change, but try the 1-2 punch combo... |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 12:04 pm Post subject: |
|
|
| Anonymous wrote: | | You need the ControlClick? I removed it, cuz in my tests, it added nothing (however, for your program, I understand if it really does something/help)... | I need ControlClick, as it increases the reliability of multiple value changes at once, fastly, e.g. setting all instruments to 0, or increasing all pitches by 1... If I remove ControlClick, after a few tests, like 10, some values are not taken over correctly, some random or maximum value is entered instead which I do not want. |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 12:11 pm Post subject: |
|
|
Well, my last statement seems not to be true, the same problem still exists even with ControlClick. The line below seems not to be reliable enough.
| Code: | | ControlSend, %CurrentStep%, {Home}+{End}, a |
Maybe I need to use the version I had before, with those %SleepTime% values inbetween, to slow down this key sequence a little. |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 12:20 pm Post subject: |
|
|
Now I am using following code, which works nicely:
| Code: | SetKeyDelay, 0, 10
Add1(CurrentStep)
{
ControlGetText, ValueEdit , %CurrentStep%, - + ÷ x
NewValueEdit := ValueEdit + 1
ControlSend, %CurrentStep%, {Home}+{End}, a
Control, EditPaste, %NewValueEdit%, %CurrentStep%, a
return
} |
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 17, 2010 1:53 pm Post subject: |
|
|
Use whatever works, but could you test this & make sure it don't work?...
| Code: | Add1(CurrentStep) {
ControlGetText, ValueEdit , %CurrentStep%, - + ÷ x
NewValueEdit := ValueEdit + 1
ControlSetText, %CurrentStep%, , a
Control, EditPaste, %NewValueEdit%, %CurrentStep%, a
return
} |
...again, it might not work, but I'm just curious... |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 644
|
Posted: Wed Mar 17, 2010 4:25 pm Post subject: |
|
|
| I tried it and it works also nicely, I should use this instead. Thanks for your help Guest. |
|
| 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
|