Skip to content

Commit

Permalink
legacy access api working
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Feb 26, 2024
1 parent d99f2c3 commit 945bb84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions nvda/nvda.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def cancel_current_speaker():
def braille(text: str):
"""Output braille with NVDA"""
nvda_client.nvdaController_brailleMessage(text)

def switch_voice():
"""Switches the voice for the screen reader"""
actions.user.tts("You must switch voice in NVDA manually")


def _ready_to_send_ipc():
Expand Down
17 changes: 9 additions & 8 deletions utils/access-focus.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ def focus_element_by_name(name: str, permissive: bool = True):
try:
element.invoke_pattern.invoke()
except Exception as e:
# try:
# pat = element.legacyiaccessible_pattern
# # https://learn.microsoft.com/en-us/windows/win32/winauto/selflag
# SELFLAG_TAKESELECTION = 2
# pat.select(2)
# except Exception as f:
try:
# https://learn.microsoft.com/en-us/windows/win32/winauto/selflag
# SELFLAG_TAKESELECTION = 2
# Ideally we would use .select() but the API doesn't work
element.legacyiaccessible_pattern.do_default_action()
except Exception as f:
actions.user.tts(f"Failed to focus {name}")
print(e)

print(e, f)
break
else:
raise ValueError(f"Element '{name}' not found")


0 comments on commit 945bb84

Please sign in to comment.