beuaaa / pywinauto_recorder

A record-replay tool to automate GUI via pywinauto
https://pywinauto-recorder.readthedocs.io/
MIT License
131 stars 24 forks source link

Taking screenshot using relative coordinates #61

Open Ashish3080 opened 1 year ago

Ashish3080 commented 1 year ago

Hi, I want to take screenshots of elements when being clicked while recording using the relative coordinates. For instance, while trying to record calculator, I clicked on the button '3' and got this in the generated script 'click(u"Three||Button%(-32.14,-18.67)")'. I want to take a screenshot as per these coordinates when this button is clicked. Could you please help me get through this issue?

github-actions[bot] commented 1 year ago

Thank you very much for sharing this first issue.

beuaaa commented 11 months ago

Hello,

Sorry for my late reply. %(-32.14,-18.67) is the relative coordinate of the click. This value is optional. These two values are percentage offsets. 0% means that it is on the left edge of the clicked element and 100% means that it is on the right edge of the element. If the value is negative or greater than 100%, it means that it is outside the clicked element.

If you want to obtain a screenshot of an element :

wrapper = find("Three||Button"") img = wrapper.capture_as_image().convert('RGB') img.save("D:\screenshot.png")

Does this answer your question?

Ashish3080 commented 10 months ago

Hi, is it possible in pywinauto_recorder to just record the elements with their element_ids with the actions performed on them so that they can be stored in a json?

beuaaa commented 10 months ago

No, this is not possible.