Skip to content

Instantly share code, notes, and snippets.

@icedmoca
Last active July 31, 2025 05:59
Show Gist options
  • Save icedmoca/031fddc6905070fa5a58492781a1e4c7 to your computer and use it in GitHub Desktop.
Save icedmoca/031fddc6905070fa5a58492781a1e4c7 to your computer and use it in GitHub Desktop.
Beat Neuralink's blue square game without a neuralink!
import pyautogui
import cv2
import numpy as np
import time
import pygetwindow as gw
import mss
import keyboard
running = False
def capture_screen():
with mss.mss() as sct:
# Get information of monitor 1
monitor = sct.monitors[1]
# Capture the screen
screenshot = sct.grab(monitor)
image = np.array(screenshot)
image = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR)
return image
def find_blue_square(image):
# Convert image to HSV color space
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# Define the blue color range based on the given color #0a84ff
lower_blue = np.array([100, 150, 200])
upper_blue = np.array([110, 255, 255])
# Create a mask for blue color
mask = cv2.inRange(hsv, lower_blue, upper_blue)
# Find contours
contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
if contours:
# Get the largest contour
contour = max(contours, key=cv2.contourArea)
x, y, w, h = cv2.boundingRect(contour)
return (x + w // 2, y + h // 2)
else:
return None
def toggle_running():
global running
running = not running
if running:
print("Started")
else:
print("Stopped")
def main():
# Register the hotkey
keyboard.add_hotkey('j', toggle_running)
# Get the Chrome window
windows = gw.getWindowsWithTitle('Chrome')
if not windows:
print("No Chrome window found.")
return
chrome_window = windows[0]
while True:
if running:
screenshot = capture_screen()
position = find_blue_square(screenshot)
if position:
x, y = position
chrome_window.activate()
pyautogui.moveTo(x, y)
pyautogui.click()
time.sleep(0.1)
else:
time.sleep(0.1)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment