Advertisement
mechagical

Simple Control Over Socket

Jun 25th, 2022 (edited)
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #Simple control over socket
  2. import numpy as np
  3. import cv2
  4. import math
  5. import socket
  6. import time
  7.  
  8. UDP_IP = "127.0.0.1"
  9. UDP_PORT = 5065
  10.  
  11. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  12.  
  13. last = (0,0)
  14.  
  15. import pyautogui
  16.  
  17. while True:
  18.     try:
  19.         pos = pyautogui.position()
  20.         if pos != last:
  21.             info = str(pos[0]) + "," +str(pos[1])
  22.             sock.sendto( (info).encode(), (UDP_IP, UDP_PORT) )
  23.             print("_"*10, "Curr Pos: "+ info, "_"*10)
  24.             last = pyautogui.position()
  25.             time.sleep(0.04);
  26.     except:
  27.         break
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement