Skip to content

Instantly share code, notes, and snippets.

@Gavriel770U
Created September 2, 2024 18:50
Show Gist options
  • Save Gavriel770U/d0db5f6883868626cf0705f775ac5725 to your computer and use it in GitHub Desktop.
Save Gavriel770U/d0db5f6883868626cf0705f775ac5725 to your computer and use it in GitHub Desktop.
Neal's circle code for perfect circle (Windows)
from pynput.mouse import Button, Controller
import time
def main() -> None:
mouse = Controller()
mouse.press(Button.left)
print("Left mouse button pressed.")
time.sleep(12)
mouse.release(Button.left)
print("Left mouse button released.")
if __name__ == "__main__":
main()
pip install pyautogui
pip install pynput
import pyautogui
import time
import math
import subprocess
def main() -> None:
for i in range(5, 0, -1):
print(i)
time.sleep(1)
w, h = pyautogui.size()
print("Drawing circle...")
cx, cy = w / 2, h / 2
r = 250
sx = cx + r
sy = cy
pyautogui.moveTo(sx, sy)
subprocess.Popen(['python', './holdmouse.py'])
j = 6
for i in range(-j*2, 360+j, j):
x = cx + r * math.cos(math.radians(i))
y = cy + r * math.sin(math.radians(i))
pyautogui.moveTo(x, y)
if __name__ == "__main__":
main()
python main.py
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment