#๐Ÿ”’ Draw a rectangle on my screen

20 messages ยท Page 1 of 1 (latest)

inland sundial
#

Would anyone know if it's possible to create a rectangle from 2 clicks on your windows screen using python? I can do it on a screenshot but not live on the screen.

scarlet orchidBOT
#

@inland sundial

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

swift zenith
inland sundial
#

I'm making an application where the user has to choose an area of his screen to capture by a screenshot with two clicks and I'd like that after these 2 clicks the area is surrounded by a rectangle.

swift zenith
#

You could probably do this with pyqt

#

draw a fully transparent widget on screen to detect clicks

#

then 2 clicks to set the bounds of the rectangle

inland sundial
#

OK thx i will try

primal slate
#

for instance you could use the pynput library which is rather straight forward to get the mouse click coordinates

#

and open a transparent window using pyQt (as fashoomp said) at the coordinates you get

#

as for "drawing a rectangle" on your screen, that would require first to open a transparent window on your full screen and then draw a rectangle inside it
might be another way to do that actually since the mouse getter can be managed by Qt itself

swift zenith
#

there's no need to use pynput in that case, you could record the coordinates using qt

primal slate
#

it works outside of its window ?

#

didnt know, mb then

swift zenith
#

no, but the transparent window would be there to capture your input

#

sort of like how the windows snipping tool works

primal slate
#

ah yes, i didn't understand your first message

#

i just said the same thing on the second part of mine ๐Ÿ˜„

scarlet orchidBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.