-
Notifications
You must be signed in to change notification settings - Fork 0
/
emulate_double_click.py
54 lines (44 loc) · 1.55 KB
/
emulate_double_click.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
#-------------------------------------------------------------------------------
# Name:
# Purpose: produce double click when press 1, press other key to stop
#
# Author:
#
# Created: 02/10/2012
# Copyright: (c) Administrator 2012
# Licence: <your licence>
#-------------------------------------------------------------------------------
import win32gui, win32api, win32con
import time
import threading
import pythoncom
import pyHook
flag = '1'
def click_event():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 )
def double_click_event():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 )
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 )
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 )
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 )
def get_flag(event):
global flag
flag = event.GetKey()
def start_hook():
hm = pyHook.HookManager()
hm.KeyDown = get_flag
hm.HookKeyboard()
pythoncom.PumpMessages()
def start_mouse():
interval = 1
while True:
time.sleep(interval)
if '1' == flag:
double_click_event()
def main():
t1 = threading.Thread(target = start_hook)
t1.start()
t2 = threading.Thread(target = start_mouse)
t2.start()
if __name__ == '__main__':
main()