Hi everyone, My name is Ramón, from Spain. I am glad to be here. I would like to ask you something about a script I am writing. I am in Windows Explorer. There are 5 items in the list view (obj.parent). I press the script gesture and a new item is created in that folder. Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear. Is there a way I can force to NVDA to refresh the view list from the script? I tried changing the focus from a list item to the list view after the new file was created but did not work, I appreciate your answer. Regards.
|
|
Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send()
2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
Thanks for your answer. F5 worked but I can't set the focus to that new file yet.
def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) # This method return the folder route file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() obj = api.getFocusObject() for itemObj in obj.parent.children: if itemObj.name == u"newFile.txt": api.setFocusObject(itemObj)
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send()
2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
OK. I had to ask again for the focus object after setting the focus.
api.setFocusObject(itemObj) obj = api.getFocusObject()
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Ramón García via groups.io Enviado el: domingo, 31 de julio de 2022 21:01 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
Thanks for your answer. F5 worked but I can't set the focus to that new file yet.
def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) # This method return the folder route file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() obj = api.getFocusObject() for itemObj in obj.parent.children: if itemObj.name == u"newFile.txt": api.setFocusObject(itemObj)
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send()
2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
This was what I wanted, thank you, Noelia, y shown me the correct way.
def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send()
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send()
2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
Hi! Just be aware that this won't work on systems that uses other languages than English. "New" in Swedish is "Ny" so you won't focus that file or folder if you let the system create it, i e sending Ctrl + Shift + N to create a new folder. If you set the name yourself it might work if you don't make the file name translatable because then you have to loop through the file name to type each letter. This wasn't meant to be a downer, just a heads up. :) Good luck! Karl-Otto Karl-Otto Rosenqvist MAWINGU Orgnr: 750804-3937 0701- 75 98 56 karl-otto@... https://mawingu.seDen 2022-07-31 kl. 23:28, skrev Ramón García via groups.io:
toggle quoted message
Show quoted text
This was what I wanted, thank you, Noelia, y shown me the correct way. def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send() -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send() 2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
You may try with obj.setfocus method too, to move the focus physically.
Enviado desde mi iPhone
toggle quoted message
Show quoted text
El 1 ago 2022, a las 10:25, Karl-Otto Rosenqvist <Karl-otto@...> escribió:
Hi! Just be aware that this won't work on systems that uses other languages than English. "New" in Swedish is "Ny" so you won't focus that file or folder if you let the system create it, i e sending Ctrl + Shift + N to create a new folder. If you set the name yourself it might work if you don't make the file name translatable because then you have to loop through the file name to type each letter.
This wasn't meant to be a downer, just a heads up. :)
Good luck!
Karl-Otto
Karl-Otto Rosenqvist MAWINGU Orgnr: 750804-3937 0701- 75 98 56 karl-otto@... https://mawingu.se
Den 2022-07-31 kl. 23:28, skrev Ramón García via groups.io: This was what I wanted, thank you, Noelia, y shown me the correct way. def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send() -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send() 2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
For some reason sending keys it works better. Thanks to Karl-Otto who gave me a good piece of advice too.
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: lunes, 1 de agosto de 2022 14:47 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
You may try with obj.setfocus method too, to move the focus physically.
Enviado desde mi iPhone
toggle quoted message
Show quoted text
El 1 ago 2022, a las 10:25, Karl-Otto Rosenqvist <Karl-otto@...> escribió:
Hi! Just be aware that this won't work on systems that uses other languages than English. "New" in Swedish is "Ny" so you won't focus that file or folder if you let the system create it, i e sending Ctrl + Shift + N to create a new folder. If you set the name yourself it might work if you don't make the file name translatable because then you have to loop through the file name to type each letter.
This wasn't meant to be a downer, just a heads up. :)
Good luck!
Karl-Otto
Karl-Otto Rosenqvist MAWINGU Orgnr: 750804-3937 0701- 75 98 56 karl-otto@... https://mawingu.se
Den 2022-07-31 kl. 23:28, skrev Ramón García via groups.io: This was what I wanted, thank you, Noelia, y shown me the correct way. def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send() -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send() 2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
Also, in case you're interested, you can see this message from Julien sent to the development list in 2019. I remembered it seeing that you prefixed a string with u"", and I have found it. In short, this is not needed though it's not harmful, but for a more readable code you may want to remove it: https://groups.io/g/nvda-devel/message/444902022-08-01 18:18 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
For some reason sending keys it works better. Thanks to Karl-Otto who gave me a good piece of advice too.
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: lunes, 1 de agosto de 2022 14:47 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
You may try with obj.setfocus method too, to move the focus physically.
Enviado desde mi iPhone
El 1 ago 2022, a las 10:25, Karl-Otto Rosenqvist <Karl-otto@...> escribió:
Hi! Just be aware that this won't work on systems that uses other languages than English. "New" in Swedish is "Ny" so you won't focus that file or folder if you let the system create it, i e sending Ctrl + Shift + N to create a new folder. If you set the name yourself it might work if you don't make the file name translatable because then you have to loop through the file name to type each letter.
This wasn't meant to be a downer, just a heads up. :)
Good luck!
Karl-Otto
Karl-Otto Rosenqvist MAWINGU Orgnr: 750804-3937 0701- 75 98 56 karl-otto@... https://mawingu.se
Den 2022-07-31 kl. 23:28, skrev Ramón García via groups.io: This was what I wanted, thank you, Noelia, y shown me the correct way. def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send() -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send() 2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|
OK, no more u"". Thanks. -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: lunes, 1 de agosto de 2022 19:11 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Also, in case you're interested, you can see this message from Julien sent to the development list in 2019. I remembered it seeing that you prefixed a string with u"", and I have found it. In short, this is not needed though it's not harmful, but for a more readable code you may want to remove it: https://groups.io/g/nvda-devel/message/444902022-08-01 18:18 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
toggle quoted message
Show quoted text
For some reason sending keys it works better. Thanks to Karl-Otto who gave me a good piece of advice too.
-----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: lunes, 1 de agosto de 2022 14:47 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus
You may try with obj.setfocus method too, to move the focus physically.
Enviado desde mi iPhone
El 1 ago 2022, a las 10:25, Karl-Otto Rosenqvist <Karl-otto@...> escribió:
Hi! Just be aware that this won't work on systems that uses other languages than English. "New" in Swedish is "Ny" so you won't focus that file or folder if you let the system create it, i e sending Ctrl + Shift + N to create a new folder. If you set the name yourself it might work if you don't make the file name translatable because then you have to loop through the file name to type each letter.
This wasn't meant to be a downer, just a heads up. :)
Good luck!
Karl-Otto
Karl-Otto Rosenqvist MAWINGU Orgnr: 750804-3937 0701- 75 98 56 karl-otto@... https://mawingu.se
Den 2022-07-31 kl. 23:28, skrev Ramón García via groups.io: This was what I wanted, thank you, Noelia, y shown me the correct way. def script_newFile(self, gesture): fgObj = api.getForegroundObject() route = "" route += self.getRoute(fgObj) file = open(route+'\\newFile.txt','a+') file.close() KeyboardInputGesture.fromName("f5").send() KeyboardInputGesture.fromName("n").send() KeyboardInputGesture.fromName("e").send() KeyboardInputGesture.fromName("w").send() KeyboardInputGesture.fromName("f2").send() -----Mensaje original----- De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz Enviado el: domingo, 31 de julio de 2022 19:39 Para: nvda-addons@nvda-addons.groups.io Asunto: Re: [nvda-addons] Refresh focus Welcome. You may show your source code for a better reply. I'd try with the redraw() method obj.redraw() or sending the f5 key to the system: from keyboardHandler import KeyboardInputGesture KeyboardInputGesture.fromName("f5").send() 2022-07-31 15:53 GMT+02:00, Ramón García via groups.io <rgmagadan@...>:
Hi everyone,
My name is Ramón, from Spain. I am glad to be here.
I would like to ask you something about a script I am writing.
I am in Windows Explorer. There are 5 items in the list view (obj.parent).
I press the script gesture and a new item is created in that folder.
Now I would like to set the focus to the new item, but when I check the children of the list view (obj.parent.childCount), the same 5 items appear.
Is there a way I can force to NVDA to refresh the view list from the script?
I tried changing the focus from a list item to the list view after the new file was created but did not work,
I appreciate your answer.
Regards.
|
|