Coloring Game

Coloring Game

Not enough ratings
How to automate your coloring game with phyton
By Moises Veras
with 2 simple phyton scripts you can chill while you see your screen being colored
   
Award
Favorite
Favorited
Unfavorite
Recomendations
I recomend that you use pycharm to run the code because it's easier to edit the code and install the libraries but you can use whatever you want
The code itself
create 2 files in a project and name them main.py and directKeys.py
copy and paste the folowing codes into them



main:
import numpy as np from PIL import ImageGrab from directKeys import click, queryMousePosition, rightClick import time import math import keyboard game_coords = [132, 1200, 55, 1000] previous_clicks = [] def dist(x1, y1, x2, y2): return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) def paint(screen): global game_coords for y in range(0, 1010 - 55, 10): for x in range(0, 1210 - 132, 10): actual_x = x + game_coords[0] actual_y = y + game_coords[2] time.sleep(0.1) rightClick(actual_x,actual_y) time.sleep(0.1) click(actual_x, actual_y) if keyboard.is_pressed('v'): return 0 print("alright we good to go") while True: mouse_pos = queryMousePosition() if keyboard.is_pressed('c'): print("♥♥♥♥ YEAH") screen = np.array(ImageGrab.grab(bbox=game_coords)) paint(screen)



directKeys:
import ctypes import time SendInput = ctypes.windll.user32.SendInput W = 0x11 A = 0x1E S = 0x1F D = 0x20 M = 0x32 K = 0x25 SPACE = 0x39 # C struct redefinitions PUL = ctypes.POINTER(ctypes.c_ulong) class KeyBdInput(ctypes.Structure): _fields_ = [("wVk", ctypes.c_ushort), ("wScan", ctypes.c_ushort), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(ctypes.Structure): _fields_ = [("uMsg", ctypes.c_ulong), ("wParamL", ctypes.c_short), ("wParamH", ctypes.c_ushort)] class MouseInput(ctypes.Structure): _fields_ = [("dx", ctypes.c_long), ("dy", ctypes.c_long), ("mouseData", ctypes.c_ulong), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class Input_I(ctypes.Union): _fields_ = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(ctypes.Structure): _fields_ = [("type", ctypes.c_ulong), ("ii", Input_I)] from ctypes import windll, Structure, c_long, byref class POINT(Structure): _fields_ = [("x", c_long), ("y", c_long)] def queryMousePosition(): pt = POINT() windll.user32.GetCursorPos(byref(pt)) return pt def rightClick(x, y): ctypes.windll.user32.SetCursorPos(x, y) ctypes.windll.user32.mouse_event(8, 0, 0, 0, 0) # right down ctypes.windll.user32.mouse_event(20, 0, 0, 0, 0) # right up def click(x, y): ctypes.windll.user32.SetCursorPos(x, y) ctypes.windll.user32.mouse_event(2, 0, 0, 0, 0) # left down ctypes.windll.user32.mouse_event(4, 0, 0, 0, 0) # left up def moveMouseTo(x, y): print(x, y) ctypes.windll.user32.SetCursorPos(x, y) def PressKey(hexKeyCode): extra = ctypes.c_ulong(0) ii_ = Input_I() ii_.ki = KeyBdInput(0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra)) x = Input(ctypes.c_ulong(1), ii_) ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x)) def ReleaseKey(hexKeyCode): extra = ctypes.c_ulong(0) ii_ = Input_I() ii_.ki = KeyBdInput(0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra)) x = Input(ctypes.c_ulong(1), ii_) ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))


Don't forget to install the following libraries:
Pillow keyboard numpy pip python-dateutil pytz setuptools six

if you don't know how to install libraries just google "How to install phyton libraries on pycharm"
Running the code
now you just have to run the main.py, open your game, open a image, press 'c' and let the program color for you.
if you want the program to stop coloring just press 'v'.
the program takes about 17 minutes to complete a section of the painting.
if you know a litlle about phyton feel free to play with the code, otherwise i wouldn't recommend it
8 Comments
Moises Veras  [author] 26 Feb, 2022 @ 9:04pm 
Vsf Ban
grammy 19 Feb, 2022 @ 10:14pm 
this code could've been done way better without AI
Eagles 22 May, 2021 @ 3:08pm 
cool man bet this was fun to work on
H4RDC0R3 27 Apr, 2021 @ 3:46pm 
why ? no fun !
Miscret 15 Apr, 2021 @ 7:18am 
So cool I've to try this one. Do u know if it works just in this, or also does in 2, 3 and 4?
||SD|| 25 Aug, 2020 @ 9:16am 
i made one using autohotkey simpel but it works check it out here

https://www.youtube.com/watch?v=szig4ake4xA&t=22s
Gharren 9 Aug, 2020 @ 1:52pm 
It's a cool little scripting challenge!
Mikki 7 Jul, 2020 @ 12:35am 
question though, if I ought to write something in word while running the script on with the game, will the pressed keys at the script registered as well on the word or just the game? or the vice versa, could my pressed keys affect the game as well?