Created
March 22, 2019 14:20
-
-
Save Orpheon/a9a7c4be5674c8c03d579973f4dd3166 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput import mouse, keyboard | |
import sys | |
import time | |
class ClickRecorder: | |
def __init__(self): | |
self.clicks = [] | |
def click(self, x, y, button, press): | |
if press and button == mouse.Button.left: | |
self.clicks.append((x, y)) | |
print(x, y, button, press) | |
elif press: | |
print(self.clicks) | |
raise IOError | |
class ClickOutput: | |
telegram_icon = (30, 373) | |
telegram_upload = (510, 1181) | |
telegram_file = (852, 743) | |
telegram_confirm = (1119, 844) | |
images = [(877, 304), (872, 327), (874, 356), (879, 378), (884, 406), (882, 429), (879, 446), (876, 474), (872, 497), (867, 523), (865, 536), (873, 556), (873, 583), (873, 607), (873, 624), (869, 663), (869, 673), (866, 700), (899, 726), (883, 749), (860, 767), (860, 788), (864, 812), (866, 838), (873, 862), (871, 881), (876, 904), (875, 925), (874, 950), (874, 974)] | |
def run(self): | |
k = keyboard.Controller() | |
m = mouse.Controller() | |
m.position = self.telegram_icon | |
m.click(mouse.Button.left) | |
time.sleep(0.1) | |
with k.pressed(keyboard.Key.shift): | |
# American keyboards can fug off | |
k.press('7') | |
k.release('7') | |
k.type("newpack") | |
time.sleep(0.1) | |
k.press(keyboard.Key.enter) | |
k.release(keyboard.Key.enter) | |
time.sleep(0.1) | |
def wait_for_enter(key): | |
if key == keyboard.Key.enter: | |
return False | |
with keyboard.Listener( | |
on_release=wait_for_enter) as listener: | |
listener.join() | |
time.sleep(0.5) | |
for image in self.images: | |
m.position = self.telegram_upload | |
m.click(mouse.Button.left) | |
time.sleep(0.5) | |
m.position = image | |
time.sleep(0.1) | |
m.click(mouse.Button.left, 2) | |
time.sleep(0.2) | |
m.position = self.telegram_file | |
time.sleep(0.1) | |
m.click(mouse.Button.left) | |
time.sleep(0.4) | |
k.press(keyboard.Key.enter) | |
time.sleep(0.2) | |
k.release(keyboard.Key.enter) | |
time.sleep(2) | |
with k.pressed(keyboard.Key.shift): | |
k.press('.') | |
k.release('.') | |
k.type("thinking") | |
with k.pressed(keyboard.Key.shift): | |
k.press('.') | |
k.release('.') | |
time.sleep(0.1) | |
k.press(keyboard.Key.enter) | |
k.release(keyboard.Key.enter) | |
time.sleep(0.2) | |
# c = ClickRecorder() | |
# with mouse.Listener( | |
# on_click=c.click) as listener: | |
# try: | |
# listener.join() | |
# except IOError as e: | |
# sys.exit(0) | |
c = ClickOutput() | |
c.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment