Tricky access to a randomly changing ControlNN

Get help with using AutoHotkey and its commands and hotkeys
Nixcalo
Posts: 26
Joined: 06 Feb 2018, 04:24

Tricky access to a randomly changing ControlNN

06 Jul 2019, 23:17

Hi fellas!

Let's see if some Autohotkey guru is able to help me.

I work with Trados Studio and I need an script to perform a particular search in a particular control within the Trados Studio window.
Here is a screenshot of the entire screen:
Sin título.jpg
Sin título.jpg (287.51 KiB) Viewed 215 times
Notice the section circled in red in the picture. Well, my intention is simple, I want to use a hotkey to, for an already highlighted text within the program, copy that text and paste it in that section (where "Troubleshooting" appears) and send an {Enter}

Simple,right' Well NO!

The difficulty seems to rise to infinity...

That controlNN for that control is something like "WindowsForms10.EDIT.app.0.3598b65_r9_ad19" and once I locate it, it's easy to access it with ControlClick (ControlFocus never worked). Ok, now the problem is that the ControlNN CHANGES. And it changes in a way I have not been able to decode. The usual format is WindowsForms10.EDIT.app.0.XXXXXXX_r9_adYY. The X's remain constant for each run of the program, although it changes from one run to another. However, the problem lies with the Y's. They change within the same program run! Apparently, if I use some other EDIT boxes (for instance, below "Concordance Search" (where State Transition appears), the ControlNN for the red-circled control will change (for example, from WindowsForms10.EDIT.app.0.3598b65_r9_ad19 to WindowsForms10.EDIT.app.0.3598b65_r9_ad112). And if I juggle a Little bit, it can adopt the forms WindowsForms10.EDIT.app.0.3598b65_r9_ad113, WindowsForms10.EDIT.app.0.3598b65_r9_ad114, WindowsForms10.EDIT.app.0.3598b65_r9_ad16, etc.

I even tried the tack of detecting the ControlNN by what I understand is the Z-order of the application. My latest strategy was to detect all Controls in the page (with WinGet and Loop, Parse), filter only the ones that contained WindowsForms10.EDIT.app.0 and then sort them, and pick up the last of the sorted list, as thought that precisely that control was be ALWAYS the EDIT control with the largest number. And it worked for several days, until today, where I found that today my target ControlNN ends in _ad16 while there is another unknown control which ends in _ad19. And that of course screws up my entire sorting strategy. :cry:

Of course, I DON'T WANT TO USE MOUSECLICK!

So how the heck to I detect that section? Is there another way to get there? I tried to use Window Spy with the hope to find some text I could use (for instance, trying to detect the words Termbase Search or something) but such words are not part of that control, WIndow Spy says absolutely nothing about that Control when I hover the mouse over it, except the ClassNN which is, as far as I have ascertained, unusable because it changes even within the same run of Trados. ahk_Class, ahk_exe or ahk_pid are global to the entire Trados software, they do not differentiate between these pseudowindows.

So really does anyone have any idea how I can get something as simple as inserting some text into that damn red circle? Something that does not depend on mouse coordinates, as they vary as well (I can always resize Windows and different monitors I use have different resolutions). As I said, ControlNN does not follow any predictable rule I could use to find that red circle, and I am not able to detect any text within that "Termbase Search" pseudowindow (it's not a real Windows window!). And if ControlNN changes randomly, HWND (ahk_id) seems to be even more random as it has no structure I can discern (something like 0x40dc6 or 0x380300)

Perhaps there is another characteristic, handle, ID number, whatever, that is unique to that control and would never change? Any ideas?

Feel free to ask anything if I didn't make myself understood… but I am lost.

P.S. Before you say it, Trados DOES provide a shortcut to insert text there, but it's a known bug of the program that it does not work... so that possibility was discarded in the first minute!

Return to “Ask For Help”

Who is online

Users browsing this forum: agrout, AHKStudent, Bing [Bot], holahapi, MannyKSoSo and 223 guests