Skip to content

Commit c3a328a

Browse files
committed
'1.4'
1 parent 5eacb00 commit c3a328a

File tree

3 files changed

+75
-4
lines changed

3 files changed

+75
-4
lines changed

Frame1.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def run(self):
417417
return
418418

419419
try:
420-
rhwnd = win32gui.WindowFromPoint(win32gui.GetCursorPos())
420+
# rhwnd = win32gui.WindowFromPoint(win32gui.GetCursorPos())
421421
s = file(script_path, 'r').read()
422422
s = json.loads(s)
423423
l = len(s)
@@ -496,3 +496,4 @@ def run(self):
496496
mself.tstop.Shown = False
497497

498498
# end of ThreadClass
499+

KeymouseGo.py

+56-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import wx
55
import time
66
import Frame1
7-
7+
import sys
8+
import json
9+
import win32ui,win32con,pythoncom,win32gui,win32process,win32api
10+
import ctypes
811

912

1013
modules ={'Frame1': [1, 'Main frame of Application', u'Frame1.py']}
@@ -16,9 +19,60 @@ def OnInit(self):
1619
self.SetTopWindow(self.main)
1720
return True
1821

22+
1923
def main():
2024
application = BoaApp(0)
2125
application.MainLoop()
2226

27+
28+
def single_run(script_path, times=1):
29+
30+
s = file(script_path, 'r').read()
31+
s = json.loads(s)
32+
l = len(s)
33+
34+
for j in range(times):
35+
36+
for i in range(0, l):
37+
38+
time.sleep(s[i][3]/1000.0)
39+
40+
if s[i][0]=='EM':
41+
42+
ctypes.windll.user32.SetCursorPos(s[i][2][0], s[i][2][1])
43+
44+
if s[i][1]=='mouse left down':
45+
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
46+
elif s[i][1]=='mouse left up':
47+
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
48+
elif s[i][1]=='mouse right down':
49+
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0)
50+
elif s[i][1]=='mouse right up':
51+
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0)
52+
53+
elif s[i][0] =='EK':
54+
55+
key_code = s[i][2][0]
56+
if key_code >= 160 and key_code <= 165:
57+
key_code = (key_code//2) - 64
58+
59+
if s[i][1]=='key down':
60+
win32api.keybd_event(key_code, 0, 0, 0)
61+
elif s[i][1]=='key up':
62+
win32api.keybd_event(key_code, 0, win32con.KEYEVENTF_KEYUP, 0)
63+
64+
2365
if __name__ == '__main__':
24-
main()
66+
67+
print sys.argv
68+
69+
if len(sys.argv) > 1:
70+
script_path = sys.argv[1]
71+
try:
72+
times = int(times = sys.argv[2])
73+
except Exception as e:
74+
times = 1
75+
single_run(script_path, times)
76+
else:
77+
main()
78+

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# KeymouseGo v1.3
1+
# KeymouseGo v1.4
22

33
功能:记录用户的鼠标键盘操作,通过触发按钮自动执行之前记录的操作,可设定执行的次数,可以理解为 `精简绿色版``按键精灵`
44

@@ -70,10 +70,26 @@
7070
+ 等待 `50ms` 后在相同位置 `抬起鼠标左键`
7171

7272

73+
# 使用命令行运行:
74+
75+
直接运行指定脚本:
76+
```
77+
> KeymouseGo.exe scripts/0314_1452.txt
78+
```
79+
80+
运行指定脚本3次:
81+
```
82+
> KeymouseGo.exe scripts/0314_1452.txt 3
83+
```
84+
85+
7386
----------------------
7487

7588
# 更新说明
7689

90+
## v1.4
91+
+ 增加命令行运行方式
92+
7793
## v1.3
7894
+ Bug 修复
7995

0 commit comments

Comments
 (0)