WindowSpy and WinGetText reporting incorrect text

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

WindowSpy and WinGetText reporting incorrect text

19 Dec 2023, 09:38

Hi,

As you can see below, both windowspy and wingettext are reporting incorrect text.
image.png
image.png (32.83 KiB) Viewed 1338 times
How should I proceed ?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: WindowSpy and WinGetText reporting incorrect text

19 Dec 2023, 10:26

It works with the control under the mouse. You might need to activate the target window first.

How you should proceed depends on your goal, whatever that is.
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

20 Dec 2023, 03:20

The control was under the mouse, WinGetTitle() returns « help »

I need WinGetText to return « test »
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

27 Dec 2023, 04:34

ControlGetText() returns an empty string, as shown below.
The image, text and button have distinct ClassNN : Button2, Static1 and Button8
image.png
image.png (51.71 KiB) Viewed 1055 times
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: WindowSpy and WinGetText reporting incorrect text

27 Dec 2023, 06:11

Please show the code you used.
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

28 Dec 2023, 03:34

Code: Select all

#y::
{
	MouseGetPos &aX, &aY, &Win, &CNNX
	Tooltip(ControlGetText(CNNX, "A"))
}

#x::
{
	Tooltip(WinGetText("A"))
}
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: WindowSpy and WinGetText reporting incorrect text

28 Dec 2023, 05:48

I would have done the following, but it sounds like that’s going to come up empty.

Code: Select all

MsgBox ControlGetText('Static1', 'help ahk_class WinDevObject ahk_exe wdtst.exe')
It seems odd that this window has these simple, distinct controls that don’t reveal their text, but that is apparently the case. The only other thing I can think to try is running the script as administrator.
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

28 Dec 2023, 11:15

I get the same result with your code and running as admin.
Should this be moved to bug reports ?

The code to reproduce is :
NextTitle("help")
Error("test")

With Windev :
https://windev.com/windev/WD-Express.htm
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: WindowSpy and WinGetText reporting incorrect text

28 Dec 2023, 11:32

TheoG wrote: Should this be moved to bug reports ?
No, it’s not an AHK bug that not all windows have their text available via standard Windows control interfaces.
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

02 Jan 2024, 04:31

Could you move it to the wish list ?
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: WindowSpy and WinGetText reporting incorrect text

02 Jan 2024, 05:16

You’re not understanding. It’s not an AHK issue. What would the wish list say? For windows where the text isn’t available in the controls, get the text anyway?

You can try other approaches like using the Acc library or OCR.
TheoG
Posts: 17
Joined: 18 Sep 2023, 05:14

Re: WindowSpy and WinGetText reporting incorrect text

02 Jan 2024, 12:21

The text has to be in there somewhere, how else would it be displayed ? And why does AHK report text that is not displayed on screen ?

Acc does not report the correct text either :
image.png
image.png (81 KiB) Viewed 307 times
I would appreciate if a developper could take a look at this.
If not, any pointers to help me debug ahk myself ?
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: WindowSpy and WinGetText reporting incorrect text

02 Jan 2024, 13:09

TheoG wrote: The text has to be in there somewhere, how else would it be displayed ?
Lots of ways. Take a look at an Excel or Chrome window and try grabbing the text from controls. Not sure why you’re insisting it has to be available by that method. There are probably more applications where the text isn’t available via that method than those that are.

TheoG wrote: If not, any pointers to help me debug ahk myself ?
Again, it’s not an AHK bug, but feel free to create a fork of AHK from the C++ source code that finds all text in all windows. Please share it when you have it solved.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: bobstoner289, Draken and 65 guests