Skip to content
Merged

Dev #137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/AutoControl.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 41 additions & 35 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
67 changes: 67 additions & 0 deletions je_auto_control/windows/message/window_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from je_auto_control.windows.core.utils.win32_ctype_input import user32
from je_auto_control.windows.window.window_hwnd import FindWindowW

PostMessageW = user32.PostMessageW
SendMessageW = user32.SendMessageW

messages = {
"WM_ACTIVATEAPP": 0x001C,
"WM_CANCELMODE": 0x001F,
"WM_CHILDACTIVATE": 0x0022,
"WM_CLOSE": 0x0010,
"WM_COMPACTING": 0x0041,
"WM_CREATE": 0x0001,
"WM_DESTROY": 0x0002,
"WM_ENABLE": 0x000A,
"WM_ENTERSIZEMOVE": 0x0231,
"WM_EXITSIZEMOVE": 0x0232,
"WM_GETICON": 0x007F,
"WM_GETMINMAXINFO": 0x0024,
"WM_INPUTLANGCHANGE": 0x0051,
"WM_INPUTLANGCHANGEREQUEST": 0x0050,
"WM_MOVE": 0x0003,
"WM_MOVING": 0x0216,
"WM_NCACTIVATE": 0x0086,
"WM_NCCALCSIZE": 0x0083,
"WM_NCCREATE": 0x0081,
"WM_NCDESTROY": 0x0082,
"WM_NULL": 0x0000,
"WM_QUERYDRAGICON": 0x0037,
"WM_QUERYOPEN": 0x0013,
"WM_QUIT": 0x0012,
"WM_SHOWWINDOW": 0x0018,
"WM_SIZE": 0x0005,
"WM_SIZING": 0x0214,
"WM_STYLECHANGED": 0x007D,
"WM_STYLECHANGING": 0x007C,
"WM_THEMECHANGED": 0x031A,
"WM_USERCHANGED": 0x0054,
"WM_WINDOWPOSCHANGED": 0x0047,
"WM_WINDOWPOSCHANGING": 0x0046
}


def send_message_to_window(window_name: str, action_message: int,
key_code_1: int, key_code_2: int):
_hwnd = FindWindowW(window_name)
post_status = SendMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status


def send_message_to_window_hwnd(_hwnd, action_message: int,
key_code_1: int, key_code_2: int):
post_status = SendMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status


def post_message_to_window(window_name: str, action_message: int,
key_code_1: int, key_code_2: int):
_hwnd = FindWindowW(window_name)
post_status = PostMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status


def post_message_to_window_hwnd(_hwnd, action_message: int,
key_code_1: int, key_code_2: int):
post_status = PostMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status
19 changes: 6 additions & 13 deletions je_auto_control/windows/window/window_hwnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
from typing import Union

from je_auto_control.windows.core.utils.win32_ctype_input import user32
from je_auto_control.windows.keyboard.win32_ctype_keyboard_control import press_key

EnumWindows = user32.EnumWindows
EnumWindowsProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))
GetWindowText = user32.GetWindowTextW
GetWindowTextLength = user32.GetWindowTextLengthW
IsWindowVisible = user32.IsWindowVisible
FindWindowW = user32.FindWindowW
PostMessageW = user32.PostMessageW
SendMessageW = user32.SendMessageW
CloseWindow = user32.CloseWindow
DestroyWindow = user32.DestroyWindow


def get_all_window_hwnd():
Expand All @@ -33,15 +32,9 @@ def get_one_window_hwnd(window_class: Union[None, str], window_name: Union[None,
return FindWindowW(window_class, window_name)


def send_key_to_window(window_name: str, action_message: int,
key_code_1: int, key_code_2: int):
_hwnd = FindWindowW(window_name)
post_status = SendMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status
def close_window(hwnd) -> bool:
return CloseWindow(hwnd)


def post_key_to_window(window_name: str, action_message: int,
key_code_1: int, key_code_2: int):
_hwnd = FindWindowW(window_name)
post_status = PostMessageW(_hwnd, action_message, key_code_1, key_code_2)
return _hwnd, post_status
def destroy_window(hwnd) -> bool:
return DestroyWindow(hwnd)
11 changes: 11 additions & 0 deletions test/manual_test/windows_window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from je_auto_control.windows.message.window_message import post_message_to_window, messages
from je_auto_control.windows.window.window_hwnd import get_all_window_hwnd

hwnd_list = get_all_window_hwnd()
print(hwnd_list)

for hwnd, name in hwnd_list:
print(hwnd, name)
if name == "Messenger":
print(post_message_to_window("Messenger", messages.get("WM_CLOSE"), 0, 0))
break