How to use controls sharing same ClassNN?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CH HAN
Posts: 31
Joined: 18 Sep 2017, 02:16
Contact:

How to use controls sharing same ClassNN?

05 Jan 2018, 15:41

00.jpg
00.jpg (12.26 KiB) Viewed 2623 times
01.jpg
01.jpg (39.75 KiB) Viewed 2623 times
02.jpg
02.jpg (41.43 KiB) Viewed 2623 times
As you can check above, controls I want to use have same ClassNN which makes me frustrated. I've tried many times many ways to control it, but I can only use first control among the controls sharing same ClassNN. Anybody has any solution about it?
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: How to use controls sharing same ClassNN?

05 Jan 2018, 16:07

Use the hWnd instead of the ClassNN, it is more likely to be unique.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to use controls sharing same ClassNN?

05 Jan 2018, 16:39

- Did you try looping through the controls and retrieving text?
- It may be that the Edit control only shows when you are renaming an item. E.g. this happens when you rename a file in Explorer.
- See the example, 'get control information for the active window (ClassNN and text)', here:
jeeswg's Notepad tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31764
- Try the window spy on a control when it does not have the focus.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: How to use controls sharing same ClassNN?

05 Jan 2018, 19:41

This might help.

IfInString, Controlname/Outputvariable, SearchString ; Addr1, Addr2, State, etc...
{
What you want to do.
}

To get the Controlname, you can use various commands:

MouseGetPos, XMpos, YMpos, WinID, OutputVariable
ControlGetText, OutputVariable [, Control, WinTitle,...]

Looks like you using either WindowSpy or AHK Window Info. Can't tell which. If that is some other too, then might want to download them or get the latest version of WindowSpy.ahk. It should be in your AutoHotkey directory. If not, you can download the ZIP of Autohotkey. They should give you the text of each control.

ControlClick can be used on the 1) text of the control, 2) name of the control (button7 for example), or 3) the X, Y coordinates of the control. So you have different ways to act on the control.
CH HAN
Posts: 31
Joined: 18 Sep 2017, 02:16
Contact:

Re: How to use controls sharing same ClassNN?

19 Jan 2018, 11:17

MaxAstro wrote:Use the hWnd instead of the ClassNN, it is more likely to be unique.
Thank you for the suggestion, but hWnd of the elements are also same. Anyway, Thank you!!
add1.jpg
add1.jpg (12.08 KiB) Viewed 2572 times
add2.jpg
add2.jpg (13.22 KiB) Viewed 2572 times
CH HAN
Posts: 31
Joined: 18 Sep 2017, 02:16
Contact:

Re: How to use controls sharing same ClassNN?

21 Jan 2018, 05:51

jeeswg wrote:- Did you try looping through the controls and retrieving text?
- It may be that the Edit control only shows when you are renaming an item. E.g. this happens when you rename a file in Explorer.
- See the example, 'get control information for the active window (ClassNN and text)', here:
jeeswg's Notepad tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31764
- Try the window spy on a control when it does not have the focus.
I've run your code on the link above, I can only check through the code that there are 2 more control having same ClassNN. I put some letter to find in controls, vText returns the last string I put in it with same control name which is Edit66. It makes me crazy I cannot use ControlSend to an element which I want to use.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to use controls sharing same ClassNN?

21 Jan 2018, 05:57

- It may be that the fields are part of the same control, and that the Edit control only appears when you a field is focused (ready to type something in). This is true in Explorer, only when you are renaming a file, does an Edit control appear.
- So a possible solution would be to use ControlClick on the control that contains all the fields, and then apply ControlGetText/ControlSetText.
- You might like to use AccViewer to investigate the program.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
CH HAN
Posts: 31
Joined: 18 Sep 2017, 02:16
Contact:

Re: How to use controls sharing same ClassNN?

22 Jan 2018, 01:27

jeeswg wrote:- It may be that the fields are part of the same control, and that the Edit control only appears when you a field is focused (ready to type something in). This is true in Explorer, only when you are renaming a file, does an Edit control appear.
- So a possible solution would be to use ControlClick on the control that contains all the fields, and then apply ControlGetText/ControlSetText.
- You might like to use AccViewer to investigate the program.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Thank you for your post and I've downloaded Acc, but I didn't get your suggestion. I'm pretty sure you didn't mean codes below because it's not working and it looks useless.

Code: Select all

ControlClick, Edit66, %WinTitle%

ControlGetText, OutputVar, Edit66, %WinTitle%
MsgBox, % OutputVar

ControlSetText, Edit66, abcdef, %WinTitle%
I can check Names of the controls sharing same classNN are different, but I don't know how I can use it.
ACC.jpg
ACC.jpg (76.21 KiB) Viewed 2523 times
ACC1.jpg
ACC1.jpg (76.68 KiB) Viewed 2523 times
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to use controls sharing same ClassNN?

22 Jan 2018, 02:21

Just out of curiosity. Aren't these web-based 'controls' ?
CH HAN
Posts: 31
Joined: 18 Sep 2017, 02:16
Contact:

Re: How to use controls sharing same ClassNN?

22 Jan 2018, 02:52

BoBo wrote:Just out of curiosity. Aren't these web-based 'controls' ?
No, it's not. It's an ordinary application run on windows.
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: How to use controls sharing same ClassNN?

22 Jan 2018, 02:55

BoBo wrote:Just out of curiosity. Aren't these web-based 'controls' ?
I googled the FNWND class and got a Power Builder hit... which well explains a lot...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dipahk, Nerafius and 197 guests