I am using pywinauto and have to copy a word from an application which doesn't retrieve any values on PrintControlIdentifiers()
command. My idea is to drag mouse from the start of the text till the end of the text by using DragMouse
command and then use Ctrl + C
command.
I used the below command for my application:
window1.DragMouse(button='left', pressed='',press_coords=(256,0),release_coords=(256,800))
But this isn't working and not throwing any error message as well. Please let me know where can I find more examples on DragMouse.
If DragMouseInput
doesn't work for you, I can suggest a workaround. The code might look like that (just a prototype, not tested):
from pywinauto import clipboard
app.Window.Control.TypeKeys('^a^c') # Ctrl+A, Ctrl+C
full_str = clipboard.GetData()
start_index = full_str.find(substring)
app.Window.Control.TypeKeys('{HOME}{RIGHT %d}+{RIGHT %d}^c' % (start_index, len(substring)))
# ^ is Ctrl, + is Shift
This approach doesn't depend on coordinates that is more resistant to screen resolution change.
To navigate to the control (if it's not in keyboard focus) you may use {TAB}
key alias (BTW, {TAB 3} == {TAB}{TAB}{TAB}
).