Date 1 - 2 of 2
How to read the full path to a focused file?
I am trying to understand it, but I don't know how. Can you send an example that will display the full path to the file in the explorer in ui.browseableMessage after pressing the keyboard shortcut?
thanks and regards
Hello!toggle quoted message Show quoted text
docPath = ""
# getting file path and name
fg = api.getForegroundObject()
# We check if we are in the Windows Explorer.
if fg.role != api.controlTypes.Role.PANE and fg.appModule.appName != "explorer":
shell = COMCreate("shell.application")
# We go through the list of open Windows Explorers to find the one that has the focus.
for window in shell.Windows():
if window.hwnd and window.hwnd == fg.windowHandle:
else: # loop exhausted
desktop_path = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
docPath = '\"' + desktop_path + '\\' + api.getDesktopObject().objectWithFocus().name + '\"'
# Now that we have the current folder, we can explore the SelectedItems collection.
docPath = '\"'+str(targetFile)+'\"'
This code was originally develloped byAlberto Buffolino for the Column review add-on...
I use it in TesseractOCR and NAPS2OCR add-ons...
NVDA portuguese team
Às 18:46 de 25/09/2022, Han Solo escreveu:
|1 - 2 of 2|