I am trying to become more familiar with programming GUI applications on Windows that interface with the OS. As a starting project, I want to build an App similar to Grammarly.
The app should do the following:
- Automatically (or currently on pressing a keyboard shortcut), it will send the contents of the current text box to a backend
- Run it by the GPT API to correct mistakes.
- Insert the corrected text back into the active text box
Step 1 and 2 work fine, I am using pywinauto.Desktop(backend="uia").window().descendants()
to find the descendant that has_keyboard_focus()
and extract the text.
However, I am having trouble with re-inserting it. Replacing the text using pywinauto did not work in all applications, so currently I am just sending ctrl+a and ctrl+v. This is not very reliable as it takes some time and sometimes ctrl+a gets sent too late, resulting in duplicate text.
Also, in the future, I want to use this e.g. in Word and it should not always replace the whole document, but for example only the current paragraph or the current selection. What is a better way to insert text back into Windows text controls?
submitted by /u/Big-Gate8277
[link] [comments]
r/learnpython I am trying to become more familiar with programming GUI applications on Windows that interface with the OS. As a starting project, I want to build an App similar to Grammarly. The app should do the following: Automatically (or currently on pressing a keyboard shortcut), it will send the contents of the current text box to a backend Run it by the GPT API to correct mistakes. Insert the corrected text back into the active text box Step 1 and 2 work fine, I am using pywinauto.Desktop(backend=”uia”).window().descendants() to find the descendant that has_keyboard_focus() and extract the text. However, I am having trouble with re-inserting it. Replacing the text using pywinauto did not work in all applications, so currently I am just sending ctrl+a and ctrl+v. This is not very reliable as it takes some time and sometimes ctrl+a gets sent too late, resulting in duplicate text. Also, in the future, I want to use this e.g. in Word and it should not always replace the whole document, but for example only the current paragraph or the current selection. What is a better way to insert text back into Windows text controls? submitted by /u/Big-Gate8277 [link] [comments]
I am trying to become more familiar with programming GUI applications on Windows that interface with the OS. As a starting project, I want to build an App similar to Grammarly.
The app should do the following:
- Automatically (or currently on pressing a keyboard shortcut), it will send the contents of the current text box to a backend
- Run it by the GPT API to correct mistakes.
- Insert the corrected text back into the active text box
Step 1 and 2 work fine, I am using pywinauto.Desktop(backend="uia").window().descendants()
to find the descendant that has_keyboard_focus()
and extract the text.
However, I am having trouble with re-inserting it. Replacing the text using pywinauto did not work in all applications, so currently I am just sending ctrl+a and ctrl+v. This is not very reliable as it takes some time and sometimes ctrl+a gets sent too late, resulting in duplicate text.
Also, in the future, I want to use this e.g. in Word and it should not always replace the whole document, but for example only the current paragraph or the current selection. What is a better way to insert text back into Windows text controls?
submitted by /u/Big-Gate8277
[link] [comments]