-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAyushSaluja_controller.py
80 lines (75 loc) · 2.57 KB
/
AyushSaluja_controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pygame, sys, pyautogui
black = (0,0,0)
pygame.init()
myfont = pygame.font.SysFont("monospace", 15)
pygame.display.set_caption('Mouse Values')
size = [240,240]
screen = pygame.display.set_mode(size)
pygame.key.set_repeat(50,50)
def adjust_speed():
return int(input())
def movemement(changex,changey):
try:
x, y = pyautogui.position()
pyautogui.moveTo(x+changex,y+changey)
except:
pass
def values():
left=myfont.render("Left", 1, (255, 255, 0))
screen.blit(left, (0, 0))
right=myfont.render("Right", 1, (255, 255, 0))
screen.blit(right, (0,30))
up=myfont.render("Up", 1, (255, 255, 0))
screen.blit(up, (0,60))
down=myfont.render("Down", 1, (255, 255, 0))
screen.blit(down, (0,90))
speed=5
start_time=1
#speed=adjust_speed() Uncomment this line to specify the speed by the user.
global clock, double_click_event, timer
double_click_event = pygame.USEREVENT + 1
timer = 0
def double_click():
x,y=pyautogui.position()
pyautogui.doubleClick(x,y,button='left')
while True:
values()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
movemement(-speed,0)
l=myfont.render(str(True), 1, (255, 255, 0))
screen.blit(l, (90,0))
if keys[pygame.K_RIGHT]:
movemement(speed, 0)
l = myfont.render(str(True), 1, (255, 255, 0))
screen.blit(l, (90,30))
if keys[pygame.K_UP]:
movemement(0,-speed)
l = myfont.render(str(True), 1, (255, 255, 0))
screen.blit(l, (90,60))
if keys[pygame.K_DOWN]:
movemement(0,speed)
l = myfont.render(str(True), 1, (255, 255, 0))
screen.blit(l, (90,90))
if event.key==pygame.K_SPACE:
if timer == 0:
pygame.time.set_timer(double_click_event, 500)
timerset = True
x, y = pyautogui.position()
pyautogui.click(x, y, button='left')
else:
if timer == 1:
pygame.time.set_timer(double_click_event, 0)
double_click()
timerset = False
if timerset:
timer = 1
else:
timer = 0
pygame.display.update()
screen.fill(black)