This repository was archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
左键点击interception #6
Open
zombob
wants to merge
10
commits into
cobrce:master
Choose a base branch
from
zombob:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1025166
左键点击interception
tbload 0c4f2a6
添加驱动文件包
tbload 51dc569
添加默认鼠标设备
tbload b54ee42
添加获取键盘设备号的脚本
tbload dee3f52
添加send_key功能演示
tbload 98c7746
修改文件名, 与主文件区分开
tbload 1ea33ca
添加鼠标移动常量
tbload 3bbd46f
通过实际点击鼠标识别哪些鼠标设备能用
tbload a2c9318
添加若干功能
tbload bcd4b4f
Merge branch 'cobrce:master' into master
zombob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 检查哪个键盘可以用 | ||
from interception import * | ||
from consts import * | ||
from stroke import * | ||
import time | ||
|
||
class ScanCode(): | ||
ESC = 1 | ||
NUM1 = 2 | ||
NUM2 = 3 | ||
NUM3 = 4 | ||
NUM4 = 5 | ||
NUM5 = 6 | ||
NUM6 = 7 | ||
NUM7 = 8 | ||
NUM8 = 9 | ||
NUM9 = 10 | ||
NUM0 = 11 | ||
M = 50 | ||
MINUS = 12 | ||
|
||
KEY_DOWN = 0 | ||
KEY_UP = 1 | ||
|
||
def send_key(device:int, scancode:int): | ||
c = interception() | ||
c.send(device, key_stroke(scancode,ScanCode.KEY_DOWN,0)) | ||
c.send(device, key_stroke(scancode,ScanCode.KEY_UP,0)) | ||
|
||
if __name__ == "__main__": | ||
# time.sleep(5) | ||
for device in range(MAX_KEYBOARD): | ||
numkey = eval('ScanCode.NUM' + str(device)) | ||
send_key(device, numkey) | ||
|
||
# 最终发送成功的设备会输出其数值 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#%% | ||
import time | ||
from interception import * | ||
from win32api import GetSystemMetrics | ||
|
||
#%% | ||
# 需要点击的坐标 | ||
x, y = 320, 200 | ||
screen_width = GetSystemMetrics(0) | ||
screen_height = GetSystemMetrics(1) | ||
|
||
# create a context for interception to use to send strokes, in this case | ||
# we won't use filters, we will manually search for the first found mouse | ||
context = interception() | ||
|
||
# loop through all devices and check if they correspond to a mouse | ||
mouseList = [] | ||
for mouse in range(MAX_DEVICES): | ||
if interception.is_mouse(mouse): | ||
mouseList.append(mouse) | ||
|
||
# no mouse we quit | ||
if (len(mouseList) == 0): | ||
print("No mouse found") | ||
exit(0) | ||
|
||
# 通过点击检查哪些鼠标可以用 | ||
for mouse in mouseList: | ||
print("Mouse: %d" % mouse) | ||
|
||
mstroke = mouse_stroke(interception_mouse_state.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN.value, | ||
interception_mouse_flag.INTERCEPTION_MOUSE_MOVE_ABSOLUTE.value, | ||
0, | ||
int((0xFFFF * x) / screen_width), | ||
int((0xFFFF * y) / screen_height), | ||
0) | ||
|
||
context.send(mouse,mstroke) | ||
|
||
mstroke.state = interception_mouse_state.INTERCEPTION_MOUSE_LEFT_BUTTON_UP.value | ||
context.send(mouse,mstroke) | ||
time.sleep(2) | ||
# %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#%% | ||
from interception import * | ||
from win32api import GetSystemMetrics | ||
#%% | ||
# 需要点击的坐标 | ||
# x,y = 553,337 | ||
x,y = 23,303 | ||
# x,y = 554,82 | ||
# get screen size | ||
screen_width = GetSystemMetrics(0) | ||
screen_height = GetSystemMetrics(1) | ||
|
||
# create a context for interception to use to send strokes, in this case | ||
# we won't use filters, we will manually search for the first found mouse | ||
context = interception() | ||
|
||
# loop through all devices and check if they correspond to a mouse | ||
mouse = 0 | ||
for i in range(MAX_DEVICES): | ||
if interception.is_mouse(i): | ||
mouse = i | ||
break | ||
|
||
# no mouse we quit | ||
if (mouse == 0): | ||
print("No mouse found") | ||
exit(0) | ||
|
||
# 鼠标14可以用 | ||
mouse = 11 | ||
|
||
# we create a new mouse stroke, initially we use set right button down, we also use absolute move, | ||
# and for the coordinate (x and y) we use center screen | ||
mstroke = mouse_stroke(interception_mouse_state.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN.value, | ||
interception_mouse_flag.INTERCEPTION_MOUSE_MOVE_ABSOLUTE.value, | ||
0, | ||
int((0xFFFF * x) / screen_width), | ||
int((0xFFFF * y) / screen_height), | ||
0) | ||
|
||
context.send(mouse,mstroke) # we send the key stroke, now the right button is down | ||
|
||
mstroke.state = interception_mouse_state.INTERCEPTION_MOUSE_LEFT_BUTTON_UP.value # update the stroke to release the button | ||
# mstroke.state = interception_mouse_state.INTERCEPTION_MOUSE_RIGHT_BUTTON_UP.value # update the stroke to release the button | ||
context.send(mouse,mstroke) #button right is up | ||
# %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from interception import * | ||
from consts import * | ||
|
||
if __name__ == "__main__": | ||
c = interception() | ||
c.set_filter(interception.is_mouse,interception_filter_mouse_state.INTERCEPTION_FILTER_MOUSE_ALL.value) | ||
# c.set_filter(interception.is_mouse,interception_filter_mouse_state.INTERCEPTION_FILTER_MOUSE_WHEEL.value) | ||
while True: | ||
device = c.wait() | ||
print('Device: %d' % device) | ||
stroke = c.receive(device) | ||
if type(stroke) is mouse_stroke: | ||
print("state: %d,\tflags: %d,\trolling: %d,\tx: %d,\ty: %d,\tinfo:%d" % (stroke.state, stroke.flags, stroke.rolling, stroke.x, stroke.y, stroke.information)) | ||
c.send(device,stroke) | ||
# hwid = c.get_HWID(device) | ||
# print(u"%s" % hwid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from interception import * | ||
from win32api import GetSystemMetrics | ||
|
||
mouse = 13 | ||
x,y = 100, 290 | ||
|
||
screen_width = GetSystemMetrics(0) | ||
screen_height = GetSystemMetrics(1) | ||
xT = int((0xFFFF * x) / screen_width) | ||
yT = int((0xFFFF * y) / screen_height) | ||
|
||
context = interception() | ||
mstroke = mouse_stroke(interception_mouse_state.INTERCEPTION_MOUSE_WHEEL.value, | ||
interception_mouse_flag.INTERCEPTION_MOUSE_MOVE_ABSOLUTE.value, | ||
120, | ||
xT, | ||
yT, | ||
0) | ||
|
||
context.send(mouse,mstroke) # we send the key stroke, now the right button is down | ||
|
||
# mstroke.state = interception_mouse_state.INTERCEPTION_MOUSE_LEFT_BUTTON_UP.value # update the stroke to release the button | ||
# mstroke.state = interception_mouse_state.INTERCEPTION_MOUSE_RIGHT_BUTTON_UP.value # update the stroke to release the button | ||
# context.send(mouse,mstroke) #button right is up | ||
# %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 检查哪个键盘可以用 | ||
from interception import * | ||
from consts import * | ||
from stroke import * | ||
import time | ||
|
||
class ScanCode(): | ||
ESC = 1 | ||
NUM1 = 2 | ||
NUM2 = 3 | ||
NUM3 = 4 | ||
NUM4 = 5 | ||
NUM5 = 6 | ||
NUM6 = 7 | ||
NUM7 = 8 | ||
NUM8 = 9 | ||
NUM9 = 10 | ||
NUM0 = 11 | ||
M = 50 | ||
MINUS = 12 | ||
|
||
KEY_DOWN = 0 | ||
KEY_UP = 1 | ||
|
||
def send_key(device:int, scancode:int): | ||
c = interception() | ||
c.send(device, key_stroke(scancode,ScanCode.KEY_DOWN,0)) | ||
c.send(device, key_stroke(scancode,ScanCode.KEY_UP,0)) | ||
|
||
if __name__ == "__main__": | ||
# time.sleep(5) | ||
for device in range(MAX_KEYBOARD): | ||
numkey = eval('ScanCode.NUM' + str(device)) | ||
send_key(device, numkey) | ||
|
||
# 最终发送成功的设备会输出其数值 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A personal preference here : I prefer not including binary files, but rather a link to their original repositories