-
Notifications
You must be signed in to change notification settings - Fork 0
/
mousePlay.py
68 lines (58 loc) · 2.32 KB
/
mousePlay.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
import time
import pyautogui
import random
def rightCord(xCord=None, yCord=None, pressTimes=1):
pyautogui.rightClick(xCord, yCord, pressTimes)
def clickCord(xCord=None, yCord=None, pressTimes=1):
pyautogui.click(xCord, yCord, pressTimes)
def moveCord(xCord=None, yCord=None, delay=0.1):
pyautogui.moveTo(xCord, yCord, delay)
# read cordFile and loop through each line
def main():
with open(cordFile+'.txt') as f:
mode, sRange, eRange = map(int, f.readline().split(' '))
if mode == 1:
for line in f.readlines()[1:]:
# print('hi')
which, xCord, yCord, pressTimes = map(int, line.split())
if which == 1:
clickCord(xCord, yCord, pressTimes)
elif which == 2:
rightCord(xCord, yCord, pressTimes)
elif mode == 2:
print(sRange, eRange)
# interval random float from sRange to eRange
for line in f.readlines()[1:]:
interval = random.uniform(sRange, eRange)
print(interval)
which, xCord, yCord, pressTimes = map(int, line.split())
moveCord(xCord, yCord, interval)
if which == 1:
clickCord(xCord, yCord, pressTimes)
elif which == 2:
rightCord(xCord, yCord, pressTimes)
elif mode == 3:
reminder = 0
for line in f.readlines()[1:]:
which, xCord, yCord, interval, pressTimes = map(
int, line.split())
# 0.6 seconds is the default prefix time
moveCord(xCord, yCord, interval - reminder - 0.6)
if which == 1:
clickCord(xCord, yCord, pressTimes)
elif which == 2:
rightCord(xCord, yCord, pressTimes)
reminder = interval
else:
print('mode not found')
if __name__ == '__main__':
cordFile = 'mousePosition'
timeSecs = int(input('program will run after (s) : '))
startTime = time.time()
# for timeSecs make countdown
while time.time() - startTime < timeSecs:
print(timeSecs - int(time.time() - startTime))
time.sleep(1)
main()
endTime = int(time.time() - startTime)
print('program runtime : ', endTime, 's')