Activating embedded word window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Activating embedded word window

Post by Spitzi » 31 Jan 2023, 17:11

Hi there.

I have an application that embeds winword in its GUI

Now I want to activate winword within this app (just how it would activate if clicked)

Code: Select all

WinActivate, ahk_exe winword.exe
unfortunately does not activate the embedded word...

Code: Select all

WinSet, Top,, ahk_exe winword.exe
does not work, either

How can I do this . Thanks in advance. Any suggestions welcome

User avatar
boiler
Posts: 16920
Joined: 21 Dec 2014, 02:44

Re: Activating embedded word window

Post by boiler » 31 Jan 2023, 17:46

See if the embedded Word window is a control with which you can use ControlFocus.

gmoises
Posts: 74
Joined: 18 Nov 2017, 16:43

Re: Activating embedded word window

Post by gmoises » 31 Jan 2023, 17:53

You can use Window Spy to get the actual WinTitle and a lot more information about that application.

Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Activating embedded word window

Post by Spitzi » 01 Feb 2023, 02:39

Hi. Thanks for your responses. Sadly, nothing works. Even trying ControlFocus - which was a great idea - led to nothing. Using WindowSpy, I see that the embeded word control has _WwG1 as name, but calling ControlFocus does not activate it.

Code: Select all

WinActivate, coris
WinSet, Top, , coris

ControlFocus, _WwG1, coris
WinActivate, ahk_class OpusApp

User avatar
boiler
Posts: 16920
Joined: 21 Dec 2014, 02:44

Re: Activating embedded word window

Post by boiler » 01 Feb 2023, 03:21

Just to be sure — is the title of the application’s window title really “coris” with a lowercase “c”? Window titles in the WinTitle parameter are case sensitive.

Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Activating embedded word window

Post by Spitzi » 12 Feb 2023, 03:03

Hi @boiler, thanks for your input.

Yes, the Window title is "coris".

Another way would be to prevent the loss of focus of the embedded winword app in the first place: in my script, I show a noActivate-Gui where the user can click on a button for a text choice to be inserted into the word document. When clicking the button, the gui window gets activated and word looses focus. Is it possible to not have a gui activated even when it is clicked on? That would solve the issue, i think.

User avatar
boiler
Posts: 16920
Joined: 21 Dec 2014, 02:44

Re: Activating embedded word window

Post by boiler » 12 Feb 2023, 05:40

Spitzi wrote: Is it possible to not have a gui activated even when it is clicked on?
Yes. See this thread.

Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Activating embedded word window

Post by Spitzi » 12 Feb 2023, 10:32

Hello @boiler

Thank you very much for pointing that out to me. Alas, still no luck. In my AHK-Skript, I generate some guis, among others a "main window". It seems like the code in the thread does not work, if the same skript generates two guis: the windows deactivate one another. The Gui does not deactivate another window, say Word, though. But I need one gui to not deactivate the other...

Here's my sample code:

Code: Select all

Gui, TestGui:New, +LastFound +AlwaysOnTop +ToolWindow -Caption -DPIscale +E0x08000000, TestGuiWindowName
Gui, TestGui:Margin , 2, 2
Gui, TestGui:Font, s12, Arial
Loop, 12
{
	handlerFunction := Func("Button").Bind(A_Index)																; bind the filePath to the function to call when the button is pressed
	Gui, TestGui:Add, Button, % "x" 5+(A_Index-1)*60 " y5 vF" A_Index " HWNDbuttonHwnd", F%A_Index%
	GuiControl +g, %buttonHwnd%, %handlerFunction%
}
Gui, TestGui:Show, x100 y200 NoActivate, TestGuiWindowName
Sleep, 1000
Gui, TestGui:Font, bold
GuiControl, TestGui:Font, Button3
Gui, TestGui:Show, x200 y300 NoActivate, TestGuiWindowName




; second gui
Gui, AnotherGui:New, , Test
Gui, AnotherGui:Add, Text, ,some text
Gui, AnotherGui:Show



Return

Button(index) {
	ToolTip % index
}

^Esc::
Reload
return
Clicking in the TestGUI deactivates the second gui "anotherGui"

User avatar
boiler
Posts: 16920
Joined: 21 Dec 2014, 02:44

Re: Activating embedded word window

Post by boiler » 12 Feb 2023, 10:57

You might consider using a parent script and a child script, where one script has only the GUI you don’t want to activate. There are various ways to have the scripts communicate so that they basically act as one.

Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Activating embedded word window

Post by Spitzi » 12 Feb 2023, 11:00

So there's no way to get the funcionality using just one script?

Post Reply

Return to “Ask for Help (v1)”