Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Execute full script
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  execute python script guy7200 1 1,574 Oct-25-2021, 09:55 PM
Last Post: Axel_Erfurt
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,233 May-18-2021, 06:31 AM
Last Post: Skaperen
  Execute DBCC CHECKDB from python script susja 1 2,061 Aug-12-2020, 02:09 AM
Last Post: susja
  Trying to write and execute first Python script garvind25 3 2,843 May-23-2020, 07:36 PM
Last Post: garvind25
  Execute script in IDLE with parameters Pavel_47 11 7,152 Mar-14-2020, 05:41 AM
Last Post: Larz60+
  How to write a script to execute a program need passing additional input? larkypython 2 2,467 Nov-23-2019, 04:38 AM
Last Post: larkypython
  Pyinstaller with Sys.Argv[] - “Failed to Execute Script”? ironfelix717 0 5,256 Aug-07-2019, 02:29 PM
Last Post: ironfelix717
  Help with PyInstaller + Script "Failed to Execute Script" ironfelix717 2 9,514 Jul-31-2019, 02:18 PM
Last Post: ironfelix717
  Pyinstaller can not execute script. negru555 0 2,468 Jan-27-2019, 05:15 PM
Last Post: negru555
  Why the file is not downloaded in full with this script? Jacklops 2 2,654 Jan-07-2019, 09:33 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020