Writing an add-on for labeling some of the edit boxes in winscp


Pranav Lal
 

Hi all,


I would like to attempt to write an add-on that will speak the prompts of
winscp edit boxes. Have any of you used this program?
The edit boxes I am referring to are the ones you get when you select "new
site" from the treeview when you launch the program. They are ip address,
port, username and password.

The problem I am having is that I cannot understand how to identify these
edit boxes. I have checked with object navigation and there is no visual
label for them. They have window handles but those change.

The way I am thinking this add-on should work is that when the user lands on
an edit box, NVDA should speak the label.

So:
1. You got focus on a control in winscp.
2. If the control is an edit box, check if it is one of the edit boxes you
have a label for.
3. If it is, speak the label.
4. If it is not, do nothing and let nvda interact as it does.

Am I thinking about this correctly?


Alberto Buffolino
 

Pranav Lal, il 25/9/2022, ha scritto:
I would like to attempt to write an add-on that will speak the prompts of
winscp edit boxes. Have any of you used this program?
Alberto:
Hi Pranav,
I used it in the past. Installed on the fly the version provided by Chocolatey (choco install winscp).
The problem I am having is that I cannot understand how to identify these
edit boxes. I have checked with object navigation and there is no visual
label for them. They have window handles but those change.
Alberto:
I see. Apparently, the most useful devInfo is windowStyle, maybe in combination with windowClass and status (protected for password edit) to ensure a stronger identification.
Indeed, I can find the labels, but with review navigation, and I'm not sure how to find from the chosen object, maybe playing with location and TextInfos generation.
1. You got focus on a control in winscp.
2. If the control is an edit box, check if it is one of the edit boxes you
have a label for.
3. If it is, speak the label.
4. If it is not, do nothing and let nvda interact as it does.
Alberto:
well, you can proceed in two ways, with chooseNVDAObjectOverlayClasses or (more simple) event_gainFocus, under a class extending AppModuleHandler.AppModule. Then, if the obj passes all checks, simply change its name (a new class for each field, to change a single property, seems quite overkill here).
Anyway, no need to define what NVDA should do.
I have been extremely synthetic, but you can find a lot of examples in add-ons. The more delicate part is, as you have seen, the object identification.
Alberto


Pranav Lal
 

Hi Alberto,

Many thanks. I'll see what I can create.

Pranav


Karl-Otto Rosenqvist
 

Hi Pranav!
I just checked and I think you can use the property windowControlID to determine what edit box has focus.

Match windowClassName and windowControlID and assign the correct name.

In the def event_NVDAObject_init(self, obj):
if obj.windowClassName == "TEdit":
if obj.windowControlID == 394728:
obj.name = "Host name or address"

if obj.windowClassName = "TUpDownEdit":
if ovj.windowControlID == "263290":
obj.name = "Port"

And so on.
I used the NVDA Python Command to execute nav.windowControlID and nav.windowClassName to get the properties of the navigator object. You initiate the Python Console with NVDA + Ctrl + Z.

Good luck!

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:17, skrev Pranav Lal:

Hi Alberto,
Many thanks. I'll see what I can create.
Pranav


Rui Fontes
 

Hello!


Are you sure those ControlID's do not change each time you launch the program?


Best regards,

Rui Fontes
NVDA portuguese team


Às 15:28 de 25/09/2022, Karl-Otto Rosenqvist escreveu:

Hi Pranav!
I just checked and I think you can use the property windowControlID to determine what edit box has focus.

Match windowClassName and windowControlID and assign the correct name.

In the def event_NVDAObject_init(self, obj):
if obj.windowClassName == "TEdit":
if obj.windowControlID == 394728:
obj.name = "Host name or address"

if obj.windowClassName = "TUpDownEdit":
if ovj.windowControlID == "263290":
obj.name = "Port"

And so on.
I used the NVDA Python Command to execute nav.windowControlID and nav.windowClassName to get the properties of the navigator object. You initiate the Python Console with NVDA + Ctrl + Z.

Good luck!

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:17, skrev Pranav Lal:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav









Rui Fontes
 

Have you tried the object labeller add-on?


You can get it from:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 15:17 de 25/09/2022, Pranav Lal escreveu:

Hi Alberto,

Many thanks. I'll see what I can create.

Pranav






Karl-Otto Rosenqvist
 

I'm totally sure. I'm using them in on eof my add ons. It's the window handle that changes each time.

Regards

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:34, skrev Rui Fontes:

Hello!
Are you sure those ControlID's do not change each time you launch the program?
Best regards,
Rui Fontes
NVDA portuguese team
Às 15:28 de 25/09/2022, Karl-Otto Rosenqvist escreveu:
Hi Pranav!
I just checked and I think you can use the property windowControlID to determine what edit box has focus.

Match windowClassName and windowControlID and assign the correct name.

In the def event_NVDAObject_init(self, obj):
if obj.windowClassName == "TEdit":
if obj.windowControlID == 394728:
obj.name = "Host name or address"

if obj.windowClassName = "TUpDownEdit":
if ovj.windowControlID == "263290":
obj.name = "Port"

And so on.
I used the NVDA Python Command to execute nav.windowControlID and nav.windowClassName to get the properties of the navigator object. You initiate the Python Console with NVDA + Ctrl + Z.

Good luck!

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:17, skrev Pranav Lal:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav










Dark Count
 

Hello

 Rui.

Did you create this add-on?


D C

On 9/25/2022 7:36 AM, Rui Fontes wrote:
Have you tried the object labeller add-on?


You can get it from:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 15:17 de 25/09/2022, Pranav Lal escreveu:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav









Rui Fontes
 

No, The author name is in manifest.ini...

author = "Leonard de Ruijter (Babbage B.V.) <leonard@...>"


Best regards,

Rui Fontes
NVDA portuguese team


Às 19:10 de 25/09/2022, Dark Count escreveu:

Hello

 Rui.

Did you create this add-on?


D C


On 9/25/2022 7:36 AM, Rui Fontes wrote:
Have you tried the object labeller add-on?


You can get it from:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 15:17 de 25/09/2022, Pranav Lal escreveu:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav












Pranav Lal
 

Hi Rui,
<snip Have you tried the object labeller add-on?
PL] No because I did not know it existed. Where is it, please?

Pranav


Rui Fontes
 

I have sent the Dropbox link...

Here it is again:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 00:46 de 26/09/2022, Pranav Lal escreveu:

Hi Rui,
<snip Have you tried the object labeller add-on?
PL] No because I did not know it existed. Where is it, please?

Pranav





Pranav Lal
 

Hi Karl-Otto,

Your approach works perfectly. The problem is that our control ids are different. So, what other option can I choose? Do I try the windowStyle instead?

Pranav

-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Karl-Otto Rosenqvist
Sent: Sunday, September 25, 2022 7:59 PM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp

Hi Pranav!
I just checked and I think you can use the property windowControlID to determine what edit box has focus.

Match windowClassName and windowControlID and assign the correct name.

In the def event_NVDAObject_init(self, obj):
if obj.windowClassName == "TEdit":
if obj.windowControlID == 394728:
obj.name = "Host name or address"

if obj.windowClassName = "TUpDownEdit":
if ovj.windowControlID == "263290":
obj.name = "Port"

And so on.
I used the NVDA Python Command to execute nav.windowControlID and nav.windowClassName to get the properties of the navigator object. You initiate the Python Console with NVDA + Ctrl + Z.

Good luck!

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:17, skrev Pranav Lal:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav







Travis Roth
 

Hi Pranav,
It appears WinSCP just sets the CtrlIDs dynamically to match window handles. So not useful. In the old days CtrlIDs were often static so the approach was more useful.
You have to find something that is constant to get a starting point.
I don’t' know why NVDA does not see the static text in the Session dialog other than it doesn't seem to be in the accessible objects anywhere when I navigate with the Navigator object.
I do notice that "File Protocol" is a combo box and it appears to be the only one.
So I suggest you use the approach of looking at position of the object in relation to the combo box. It appears all edit fields come after the combo box in the object hierarchy, however note they do not match the tab order, e.g., Port is the first accessible object after the combo box. c
Some pseudocode:

def event_NVDAObject_init(self, obj):
if obj.simpleParent.name == "Session": #try to identify the right window
if obj.role == Role.COMBOBOX: obj.name = "File Protocol"
elif obj.role == Role.EDITABLETEXT: obj.name = findSessionEditFieldNames(obj)
#end if session

def findSessionEditFieldNames(self, obj):
names = ['Port', ...] #put the names in this list in the reverse accessible object order back to the combo box
i = 0
previousObj = obj.simplePrevious
while previousObj.role != Role.COMBOBOX and I <10: #set a safety so we don't make infinite loop and update this number to the last valid index of the names list I didn't count them
i= I + 1
previousObj = previousObj.simplePrevious
# end while
return names[i]

-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Pranav Lal
Sent: Sunday, September 25, 2022 7:25 PM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp

Hi Karl-Otto,

Your approach works perfectly. The problem is that our control ids are different. So, what other option can I choose? Do I try the windowStyle instead?

Pranav
-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Karl-Otto Rosenqvist
Sent: Sunday, September 25, 2022 7:59 PM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp

Hi Pranav!
I just checked and I think you can use the property windowControlID to determine what edit box has focus.

Match windowClassName and windowControlID and assign the correct name.

In the def event_NVDAObject_init(self, obj):
if obj.windowClassName == "TEdit":
if obj.windowControlID == 394728:
obj.name = "Host name or address"

if obj.windowClassName = "TUpDownEdit":
if ovj.windowControlID == "263290":
obj.name = "Port"

And so on.
I used the NVDA Python Command to execute nav.windowControlID and nav.windowClassName to get the properties of the navigator object. You initiate the Python Console with NVDA + Ctrl + Z.

Good luck!

Karl-Otto

Karl-Otto Rosenqvist
MAWINGU
Orgnr: 750804-3937
0701- 75 98 56
karl-otto@...
https://mawingu.se

Den 2022-09-25 kl. 16:17, skrev Pranav Lal:
Hi Alberto,

Many thanks. I'll see what I can create.

Pranav







Pranav Lal
 

Hi Rui,

When I focus on the edit box using this add-on, I do not see any attribute that I could use as a permanent identifier for said edit box.

Pranav

-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Rui Fontes
Sent: Monday, September 26, 2022 5:45 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp

I have sent the Dropbox link...

Here it is again:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 00:46 de 26/09/2022, Pranav Lal escreveu:
Hi Rui,
<snip Have you tried the object labeller add-on?
PL] No because I did not know it existed. Where is it, please?

Pranav






Tyler Spivey
 

Have you raised an issue in the WinSCP forum? If so, where is it?
This should be trivial to fix on the WinSCP side, saving you a lot of work.

On 10/15/2022 8:19 AM, Pranav Lal wrote:
Hi Rui,
When I focus on the edit box using this add-on, I do not see any attribute that I could use as a permanent identifier for said edit box.
Pranav
-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Rui Fontes
Sent: Monday, September 26, 2022 5:45 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp
I have sent the Dropbox link...
Here it is again:
https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.nvda-addon?dl=1
Best regards,
Rui Fontes
NVDA portuguese team
Às 00:46 de 26/09/2022, Pranav Lal escreveu:
Hi Rui,
<snip Have you tried the object labeller add-on?
PL] No because I did not know it existed. Where is it, please?

Pranav






Pranav Lal
 

Hi Tyler,

As of now, I have not raised the issue but I will.

-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Tyler Spivey via groups.io
Sent: Saturday, October 15, 2022 9:04 PM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the edit boxes in winscp

Have you raised an issue in the WinSCP forum? If so, where is it?
This should be trivial to fix on the WinSCP side, saving you a lot of work.

On 10/15/2022 8:19 AM, Pranav Lal wrote:
Hi Rui,

When I focus on the edit box using this add-on, I do not see any attribute that I could use as a permanent identifier for said edit box.

Pranav
-----Original Message-----
From: nvda-addons@nvda-addons.groups.io
<nvda-addons@nvda-addons.groups.io> On Behalf Of Rui Fontes
Sent: Monday, September 26, 2022 5:45 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Writing an add-on for labeling some of the
edit boxes in winscp

I have sent the Dropbox link...

Here it is again:

https://www.dropbox.com/s/caz91dlt6lxsvok/objEnhancer_2019.2beta1_Gen.
nvda-addon?dl=1


Best regards,

Rui Fontes
NVDA portuguese team


Às 00:46 de 26/09/2022, Pranav Lal escreveu:
Hi Rui,
<snip Have you tried the object labeller add-on?
PL] No because I did not know it existed. Where is it, please?

Pranav