Aug-06-2020, 08:09 PM
Hi dear users, in this code my function detects mouse click and while loop is refreshing x and y positions of mouse. I need these values together but my program is not executing. When i put while loop up, only while loop works. When i put function up, only function works. How to run them together ?
Thank you
Thank you
import win32gui from pynput.mouse import Listener import time counter = 0 def on_click(x, y, button, pressed): if pressed: global counter counter+=1 print(counter) with Listener(on_click=on_click) as listener: listener.join() while True: x, y = win32gui.GetCursorPos() print(x,y) time.sleep(2)
My github:
https://github.com/Samuel-Bachorik
https://github.com/Samuel-Bachorik