Help with ControlSend

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ndiaz
Posts: 73
Joined: 10 Jan 2017, 17:05
Contact:

Help with ControlSend

31 Jan 2021, 00:22

Hello,

I'm trying to create a script that will send either a space or the letter r to a control in a subtitling program called Aegisub. The control in question is an audio waveform, and this would cause the selected portion of the audio to be played while retaining focus in a text editing window, instead of having to switch focus back and forth between the waveform and the text editing window.

I thought the following would work, but nothing happens when I press the hotkey:

Code: Select all

F2::
ControlSend, wxWindowNR11, {Space}, ahk_exe aegisub64.exe
Return
I got the control name with Window Spy.

What am I missing?

Thank you in advance!
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Help with ControlSend

31 Jan 2021, 07:52

Ensure that your target window is not minimized.

Unfortunately, ControlSend does not work with all programs.
User avatar
MostWanted
Posts: 11
Joined: 03 Jan 2021, 07:46
Contact:

Re: Help with ControlSend

31 Jan 2021, 08:03

I would suggest to add a few functions.
1. As it was said - to activate window
2. To wait for a window to be activate
3. To wait for a visible button that you expect to have in your window. in order for script to be more accurate
4. And only then send needed control.

Some kind of:

Code: Select all

WinActivate Wintitle ; 
WinWaitActive Wintitle
Sleep, 200
Loop {
     Sleep, 200
     ControlGet bEnabled, Visible,, ButtonName, Wintitle ; wait for visile button
	 If bEnabled
	 Break
}

ControlSend, wxWindowNR11, {Space}, ahk_exe aegisub64.exe

ndiaz
Posts: 73
Joined: 10 Jan 2017, 17:05
Contact:

Re: Help with ControlSend

31 Jan 2021, 09:52

Thank you! This particular control doesn't seem to respond to ControlSend (other controls on the same window do, so this was disappointing), so I ended up using ControlClick, then a Send command and then ControlClick again to switch back to the text box. Not very elegant, but gets the job done.

By the way, I had made a mistake earlier when posting and had written the wrong control name. I'm leaving this here in case it helps anybody else working with Aegisub.

Code: Select all

F2::
ControlClick, wxWindowNR6,  ahk_exe aegisub64.exe ;clicks waveform panel
Send {Space} ;plays current line
ControlClick, wxWindowNR11,  ahk_exe aegisub64.exe  ;clicks subtitle edit box
Return
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: Help with ControlSend

31 Jan 2021, 10:42

@ndiaz I tried to much to send control for Aegisub if window minized or inactived :( , but Unfortunately I agree with mikey ControlSend does not work with all programs .

ControlClick work with me if window active, but send control not work ..

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: big-jg, Bing [Bot], JnLlnd and 209 guests