Page 1 of 1

How to use controls sharing same ClassNN?

Posted: 05 Jan 2018, 15:41
by CH HAN
00.jpg
00.jpg (12.26 KiB) Viewed 1570 times
01.jpg
01.jpg (39.75 KiB) Viewed 1570 times
02.jpg
02.jpg (41.43 KiB) Viewed 1570 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?

Re: How to use controls sharing same ClassNN?

Posted: 05 Jan 2018, 16:07
by MaxAstro
Use the hWnd instead of the ClassNN, it is more likely to be unique.

Re: How to use controls sharing same ClassNN?

Posted: 05 Jan 2018, 16:39
by jeeswg
- 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.

Re: How to use controls sharing same ClassNN?

Posted: 05 Jan 2018, 19:41
by SOTE
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.

Re: How to use controls sharing same ClassNN?

Posted: 19 Jan 2018, 11:17
by CH HAN
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 1519 times
add2.jpg
add2.jpg (13.22 KiB) Viewed 1519 times

Re: How to use controls sharing same ClassNN?

Posted: 21 Jan 2018, 05:51
by CH HAN
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.

Re: How to use controls sharing same ClassNN?

Posted: 21 Jan 2018, 05:57
by jeeswg
- 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

Re: How to use controls sharing same ClassNN?

Posted: 22 Jan 2018, 01:27
by CH HAN
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 1470 times
ACC1.jpg
ACC1.jpg (76.68 KiB) Viewed 1470 times

Re: How to use controls sharing same ClassNN?

Posted: 22 Jan 2018, 02:21
by BoBo
Just out of curiosity. Aren't these web-based 'controls' ?

Re: How to use controls sharing same ClassNN?

Posted: 22 Jan 2018, 02:52
by CH HAN
BoBo wrote:Just out of curiosity. Aren't these web-based 'controls' ?
No, it's not. It's an ordinary application run on windows.

Re: How to use controls sharing same ClassNN?

Posted: 22 Jan 2018, 02:55
by icuurd12b42
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...