![]() |
Execute full script - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Execute full script (/thread-28863.html) |
Execute full script - samuelbachorik - Aug-06-2020 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 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) |