forked from deepd/light-remote-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
74 lines (63 loc) · 1.73 KB
/
utils.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
import pygame
from pygame.locals import *
import autopy
from autopy.mouse import CENTER_BUTTON
from autopy.mouse import RIGHT_BUTTON
from autopy.mouse import LEFT_BUTTON
class MouseClass:
def getMouseValues(self,done):
(ch, LB, CB, RB) = ('None',0, 0, 0)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
done = True
else:
print pygame.key.name(event.key)
ch = pygame.key.name(event.key)
elif event.type == pygame.MOUSEBUTTONDOWN:
print "in mousebuttondown"
print "mouse : %d" % event.button
if event.button == 1:
LB = 1
elif event.button == 2:
CB = 1
elif event.button == 3:
RB = 1
(X,Y) = pygame.mouse.get_pos()
#print "%d %d %d %d %d" %(X ,Y ,LB ,CB ,RB)
return (ch, X, Y, LB, CB, RB)
def setMouseValues(self, (ch, X, Y, LB, CB, RB)):
autopy.mouse.move(int(X),int(Y))
if " " in ch:
ch = ch.split(" ")[1]
if len(ch) == 1:
autopy.key.toggle(ch,True)
elif ch == "space":
autopy.key.toggle(' ',True)
else:
#keypressed = autopy.key.K_+ch.upper()
try:
autopy.key.toggle(eval("autopy.key.K_"+ch.upper()), True)
except:
pass
if LB == 1:
autopy.mouse.click(LEFT_BUTTON)
elif CB == 1:
autopy.mouse.click(CENTER_BUTTON)
elif RB == 1:
autopy.mouse.click(RIGHT_BUTTON)
if __name__ == '__main__' :
pygame.init()
screen = pygame.display.set_mode((1440,900))
done = False
mi = MouseClass()
while not done:
(ch, X, Y, LB, CB, RB) = mi.getMouseValues(done)
print "%c %d %d %d %d %d" %(ch, X, Y, LB, CB, RB)
#img = pygame.image.load('foo.png')
#screen.blit(img,(0,0))
# pygame.display.flip()
#Mouse : [X,Y,LB,RB,CB]