AutoHotkey Community

It is currently May 27th, 2012, 5:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: December 30th, 2009, 8:40 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2009, 9:47 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2009, 10:16 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 1:54 am 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 5:19 am 
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...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 12:19 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 12:28 pm 
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...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 1:04 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 1:11 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 1:20 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 2:53 pm 
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...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 5:25 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
I tried it and it works also nicely, I should use this instead. Thanks for your help Guest.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Google Feedfetcher, mrhobbeys, rbrtryn and 58 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