|
|
@ -16,6 +16,7 @@ inList = [
|
|
|
|
# "ValueInt": "" # MOVE: point count
|
|
|
|
# "ValueInt": "" # MOVE: point count
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
gMoveWaitNextPointSecondsMaxFloat = 5
|
|
|
|
gMoveWaitNextPointPercentFloat = 4
|
|
|
|
gMoveWaitNextPointPercentFloat = 4
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
gMovePrevious = None # {"EventDatetime": datetime.datetime.now(), "XInt": None, "YInt": None}
|
|
|
|
gMovePrevious = None # {"EventDatetime": datetime.datetime.now(), "XInt": None, "YInt": None}
|
|
|
@ -50,31 +51,104 @@ def on_move(x, y):
|
|
|
|
gMovePrevious = {"EventDatetime": lNowDatetime, "XInt": x, "YInt": y}
|
|
|
|
gMovePrevious = {"EventDatetime": lNowDatetime, "XInt": x, "YInt": y}
|
|
|
|
gMovePointCountInt = gMovePointCountInt + 1
|
|
|
|
gMovePointCountInt = gMovePointCountInt + 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Add in result list
|
|
|
|
if "left" not in SpecialKeyList:
|
|
|
|
lResult = {
|
|
|
|
pass
|
|
|
|
"EventStartDatetime": gMoveFirstDatetime,
|
|
|
|
# Add in result list
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
#lResult = {
|
|
|
|
"EventTypeStr": "MOVE", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
# "EventStartDatetime": gMoveFirstDatetime,
|
|
|
|
"ValueInt": gMovePointCountInt # MOVE: point count
|
|
|
|
# "EventEndDatetime": lNowDatetime,
|
|
|
|
}
|
|
|
|
# "EventTypeStr": "MOVE", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
inList.append(lResult)
|
|
|
|
# "ValueInt": gMovePointCountInt # MOVE: point count
|
|
|
|
print(lResult)
|
|
|
|
#}
|
|
|
|
# Close the move
|
|
|
|
#inList.append(lResult)
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
#print(lResult)
|
|
|
|
gMovePrevious = None
|
|
|
|
## Close the move
|
|
|
|
gMovePointCountInt = None
|
|
|
|
#gMoveWaitNextPointSecondsFloat = None
|
|
|
|
gMoveFirstDatetime= None
|
|
|
|
#gMovePrevious = None
|
|
|
|
|
|
|
|
#gMovePointCountInt = None
|
|
|
|
|
|
|
|
#gMoveFirstDatetime= None
|
|
|
|
#print('Pointer moved to {0}'.format(
|
|
|
|
#print('Pointer moved to {0}'.format(
|
|
|
|
# (x, y)))
|
|
|
|
# (x, y)))
|
|
|
|
|
|
|
|
|
|
|
|
def on_click(x, y, button, pressed):
|
|
|
|
def on_click(inButtonEvent):
|
|
|
|
print('{0} at {1}'.format(
|
|
|
|
global SpecialKeyList
|
|
|
|
'Pressed' if pressed else 'Released',
|
|
|
|
global gMovePrevious
|
|
|
|
(x, y)))
|
|
|
|
global gMoveWaitNextPointSecondsFloat
|
|
|
|
print(button)
|
|
|
|
global gMoveWaitNextPointPercentFloat
|
|
|
|
if not pressed:
|
|
|
|
global gMovePointCountInt
|
|
|
|
# Stop listener
|
|
|
|
global gMoveFirstDatetime
|
|
|
|
return True
|
|
|
|
lNowDatetime = datetime.datetime.now()
|
|
|
|
|
|
|
|
if inButtonEvent.button=="left" and inButtonEvent.event_type == "down":
|
|
|
|
|
|
|
|
SpecialKeyList.append("left")
|
|
|
|
|
|
|
|
# Close the previous move action
|
|
|
|
|
|
|
|
if gMovePrevious is not None:
|
|
|
|
|
|
|
|
# Add in result list
|
|
|
|
|
|
|
|
lResult = {
|
|
|
|
|
|
|
|
"EventStartDatetime": gMoveFirstDatetime,
|
|
|
|
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventTypeStr": "MOVE", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
|
|
|
|
"ValueInt": gMovePointCountInt # MOVE: point count
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inList.append(lResult)
|
|
|
|
|
|
|
|
print(lResult)
|
|
|
|
|
|
|
|
# Close the move
|
|
|
|
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
|
|
|
|
gMovePrevious = None
|
|
|
|
|
|
|
|
gMovePointCountInt = None
|
|
|
|
|
|
|
|
gMoveFirstDatetime = None
|
|
|
|
|
|
|
|
elif inButtonEvent.button=="left" and inButtonEvent.event_type == "up":
|
|
|
|
|
|
|
|
if "left" in SpecialKeyList: SpecialKeyList.remove("left")
|
|
|
|
|
|
|
|
# Close the previous move action
|
|
|
|
|
|
|
|
if gMovePrevious is not None:
|
|
|
|
|
|
|
|
# Add in result list
|
|
|
|
|
|
|
|
lResult = {
|
|
|
|
|
|
|
|
"EventStartDatetime": gMoveFirstDatetime,
|
|
|
|
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventTypeStr": "SELECT", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
|
|
|
|
"ValueInt": gMovePointCountInt # MOVE: point count
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inList.append(lResult)
|
|
|
|
|
|
|
|
print(lResult)
|
|
|
|
|
|
|
|
# Close the move
|
|
|
|
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
|
|
|
|
gMovePrevious = None
|
|
|
|
|
|
|
|
gMovePointCountInt = None
|
|
|
|
|
|
|
|
gMoveFirstDatetime = None
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Add in result list
|
|
|
|
|
|
|
|
lResult = {
|
|
|
|
|
|
|
|
"EventStartDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventTypeStr": "CLICK", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
|
|
|
|
"ValueInt": 'left' # MOVE: point count
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inList.append(lResult)
|
|
|
|
|
|
|
|
print(lResult)
|
|
|
|
|
|
|
|
# Close the move
|
|
|
|
|
|
|
|
gMoveWaitNextPointSecondsFloat = None
|
|
|
|
|
|
|
|
gMovePrevious = None
|
|
|
|
|
|
|
|
gMovePointCountInt = None
|
|
|
|
|
|
|
|
gMoveFirstDatetime = None
|
|
|
|
|
|
|
|
elif inButtonEvent.button=="right" and inButtonEvent.event_type == "up":
|
|
|
|
|
|
|
|
# Add in result list
|
|
|
|
|
|
|
|
lResult = {
|
|
|
|
|
|
|
|
"EventStartDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventTypeStr": "CLICK", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
|
|
|
|
"ValueInt": 'right' # MOVE: point count
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inList.append(lResult)
|
|
|
|
|
|
|
|
print(lResult)
|
|
|
|
|
|
|
|
elif inButtonEvent.button=="middle" and inButtonEvent.event_type == "up":
|
|
|
|
|
|
|
|
# Add in result list
|
|
|
|
|
|
|
|
lResult = {
|
|
|
|
|
|
|
|
"EventStartDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventEndDatetime": lNowDatetime,
|
|
|
|
|
|
|
|
"EventTypeStr": "CLICK", # MOVE | CLICK | SCROLL | SELECT
|
|
|
|
|
|
|
|
"ValueInt": 'middle' # MOVE: point count
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inList.append(lResult)
|
|
|
|
|
|
|
|
print(lResult)
|
|
|
|
|
|
|
|
|
|
|
|
def on_scroll(x, y, dx, dy):
|
|
|
|
def on_scroll(x, y, dx, dy):
|
|
|
|
print('Scrolled {0} at {1}'.format(
|
|
|
|
print('Scrolled {0} at {1}'.format(
|
|
|
@ -97,15 +171,19 @@ def on_scroll(x, y, dx, dy):
|
|
|
|
def Test(inArg):
|
|
|
|
def Test(inArg):
|
|
|
|
if type(inArg) is mouse_new._mouse_event.MoveEvent:
|
|
|
|
if type(inArg) is mouse_new._mouse_event.MoveEvent:
|
|
|
|
on_move(x = inArg.x, y = inArg.y)
|
|
|
|
on_move(x = inArg.x, y = inArg.y)
|
|
|
|
|
|
|
|
elif type(inArg) is mouse_new._mouse_event.ButtonEvent:
|
|
|
|
|
|
|
|
on_click(inButtonEvent = inArg)
|
|
|
|
|
|
|
|
elif type(inArg) is mouse_new._mouse_event.WheelEvent:
|
|
|
|
|
|
|
|
print(inArg)
|
|
|
|
mouse_new.hook(Test)
|
|
|
|
mouse_new.hook(Test)
|
|
|
|
|
|
|
|
|
|
|
|
import pprint
|
|
|
|
import pprint
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
# Check move interval
|
|
|
|
# Check move interval
|
|
|
|
lNowDatetime = datetime.datetime.now()
|
|
|
|
lNowDatetime = datetime.datetime.now()
|
|
|
|
if gMovePrevious is not None and gMoveWaitNextPointSecondsFloat is not None:
|
|
|
|
if gMovePrevious is not None and gMoveWaitNextPointSecondsMaxFloat is not None and "left" not in SpecialKeyList:
|
|
|
|
lNewOldDeltaSecondsFloat = (lNowDatetime - gMovePrevious["EventDatetime"]).total_seconds()
|
|
|
|
lNewOldDeltaSecondsFloat = (lNowDatetime - gMovePrevious["EventDatetime"]).total_seconds()
|
|
|
|
if lNewOldDeltaSecondsFloat > gMoveWaitNextPointSecondsFloat:
|
|
|
|
if lNewOldDeltaSecondsFloat > gMoveWaitNextPointSecondsMaxFloat:
|
|
|
|
# Add in result list
|
|
|
|
# Add in result list
|
|
|
|
lResult = {
|
|
|
|
lResult = {
|
|
|
|
"EventStartDatetime": gMoveFirstDatetime,
|
|
|
|
"EventStartDatetime": gMoveFirstDatetime,
|
|
|
|