问题描述
import time
import ctypes
import threading
user32 = ctypes.windll.user32
mouse_clicks = 0
keystrokes = 0
def getKeyPressed():
global mouse_clicks
global keystrokes
for i in range(0,256):
if user32.GetAsyncKeyState(i):
# if not i == 19:
# print "pressed %d and st = %d " % (i,user32.GetAsyncKeyState(i))
if i == 1:
mouse_clicks += 1
print "left"
return time.time()
elif 32 < i < 127:
keystrokes += 1
return None
def pr():
global mouse_clicks
global keystrokes
while True:
print "mouse = %d and key = %d "% (mouse_clicks,keystrokes)
time.sleep(1)
th = threading.Thread(target=pr)
th.start()
while True:
getKeyPressed()
上面的代码一次按一次会产生多次点击结果 如何通过修改上述程序来获得正确的击键次数和点击次数?
解决方法
var nonDuplicatedPoints = from p in points1
group p by p into g
where g.Count() == 1
select g.Key;