-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JE-Chen/dev
Dev
- Loading branch information
Showing
13 changed files
with
262 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 @@ | ||
from je_auto_control.linux_with_x11.listener import * |
This file contains 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 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 @@ | ||
from je_auto_control.linux_with_x11.record import * |
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion
3
...ndows/keyboard/win32_keyboard_listener.py → .../windows/keyboard/win32_keyboard_check.py
This file contains 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 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 @@ | ||
from je_auto_control.windows.listener import * |
59 changes: 59 additions & 0 deletions
59
je_auto_control/windows/listener/win32_keyboard_listener.py
This file contains 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,59 @@ | ||
from ctypes import * | ||
from ctypes.wintypes import MSG | ||
|
||
user32 = windll.user32 | ||
kernel32 = windll.kernel32 | ||
|
||
wm_keydown = 0x100 | ||
|
||
|
||
class Win32Listener: | ||
|
||
def __init__(self, hook_event_code_int): | ||
self.hooked = None | ||
self.hook_event_code_int = hook_event_code_int | ||
|
||
def set_win32_hook(self, point): | ||
self.hooked = user32.SetWindowsHookExA( | ||
self.hook_event_code_int, | ||
point, | ||
0, | ||
0 | ||
) | ||
if not self.hooked: | ||
return False | ||
return True | ||
|
||
def remove_win32_hook_proc(self): | ||
if self.hooked is None: | ||
return | ||
user32.UnhookWindowsHookEx(self.hooked) | ||
self.hooked = None | ||
|
||
def win32_hook_proc(self, code, w_param, l_param): | ||
if w_param is not wm_keydown: | ||
return user32.CallNextHookEx(self.hooked, code, w_param, l_param) | ||
# int to hex | ||
temp = hex(l_param[0] & 0xFFFFFFFF) | ||
print("Hooked Key: " + temp) | ||
print(int(temp, 16)) | ||
return user32.CallNextHookEx(self.hooked, code, w_param, l_param) | ||
|
||
def get_function_pointer(self, function): | ||
win_function = WINFUNCTYPE(c_int, c_int, c_int, POINTER(c_void_p)) | ||
return win_function(function) | ||
|
||
def start_listener(self): | ||
pointer = self.get_function_pointer(self.win32_hook_proc) | ||
if self.set_win32_hook(pointer): | ||
print("start listener") | ||
else: | ||
print("failed to start") | ||
message = MSG() | ||
user32.GetMessageA(byref(message), 0, 0, 0) | ||
|
||
|
||
if __name__ == "__main__": | ||
wh_keyboard_ll = 13 | ||
win32_listener = Win32Listener(wh_keyboard_ll) | ||
win32_listener.start_listener() |
This file contains 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,52 @@ | ||
from ctypes import * | ||
from ctypes.wintypes import MSG | ||
|
||
user32 = windll.user32 | ||
kernel32 = windll.kernel32 | ||
|
||
|
||
class Win32Listener: | ||
|
||
def __init__(self, hook_event_code_int): | ||
self.hooked = None | ||
self.hook_event_code_int = hook_event_code_int | ||
|
||
def set_win32_hook(self, point): | ||
self.hooked = user32.SetWindowsHookExA( | ||
self.hook_event_code_int, | ||
point, | ||
0, | ||
0 | ||
) | ||
if not self.hooked: | ||
return False | ||
return True | ||
|
||
def remove_win32_hook_proc(self): | ||
if self.hooked is None: | ||
return | ||
user32.UnhookWindowsHookEx(self.hooked) | ||
self.hooked = None | ||
|
||
def win32_hook_proc(self, code, w_param, l_param): | ||
# extend this class to rewrite this hook proc | ||
return user32.CallNextHookEx(self.hooked, code, w_param, l_param) | ||
|
||
def get_function_pointer(self, function): | ||
win_function = WINFUNCTYPE(c_int, c_int, c_int, POINTER(c_void_p)) | ||
return win_function(function) | ||
|
||
def start_listener(self): | ||
pointer = self.get_function_pointer(self.win32_hook_proc) | ||
if self.set_win32_hook(pointer): | ||
print("start listener") | ||
else: | ||
print("failed to start") | ||
message = MSG() | ||
user32.GetMessageA(byref(message), 0, 0, 0) | ||
|
||
|
||
if __name__ == "__main__": | ||
wh_keyboard_ll = 13 | ||
win32_listener = Win32Listener(wh_keyboard_ll) | ||
win32_listener.start_listener() |
This file contains 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,58 @@ | ||
from ctypes import * | ||
from ctypes.wintypes import MSG | ||
|
||
from je_auto_control.windows.mouse.win32_ctype_mouse_control import position | ||
|
||
user32 = windll.user32 | ||
kernel32 = windll.kernel32 | ||
|
||
wm_mouse_key_code = [0x0201, 0x0204] | ||
|
||
|
||
class Win32Listener: | ||
|
||
def __init__(self, hook_event_code_int): | ||
self.hooked = None | ||
self.hook_event_code_int = hook_event_code_int | ||
|
||
def set_win32_hook(self, point): | ||
self.hooked = user32.SetWindowsHookExA( | ||
self.hook_event_code_int, | ||
point, | ||
0, | ||
0 | ||
) | ||
if not self.hooked: | ||
return False | ||
return True | ||
|
||
def remove_win32_hook_proc(self): | ||
if self.hooked is None: | ||
return | ||
user32.UnhookWindowsHookEx(self.hooked) | ||
self.hooked = None | ||
|
||
def win32_hook_proc(self, code, w_param, l_param): | ||
if w_param not in wm_mouse_key_code: | ||
return user32.CallNextHookEx(self.hooked, code, w_param, l_param) | ||
print(position()) | ||
return user32.CallNextHookEx(self.hooked, code, w_param, l_param) | ||
|
||
def get_function_pointer(self, function): | ||
win_function = WINFUNCTYPE(c_int, c_int, c_int, POINTER(c_void_p)) | ||
return win_function(function) | ||
|
||
def start_listener(self): | ||
pointer = self.get_function_pointer(self.win32_hook_proc) | ||
if self.set_win32_hook(pointer): | ||
print("start listener") | ||
else: | ||
print("failed to start") | ||
message = MSG() | ||
user32.GetMessageA(byref(message), 0, 0, 0) | ||
|
||
|
||
if __name__ == "__main__": | ||
wh_mouse_ll = 14 | ||
win32_listener = Win32Listener(wh_mouse_ll) | ||
win32_listener.start_listener() |
Empty file.
This file contains 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