Skip to content

Commit

Permalink
fix: win32 null hwnd not work
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Oct 29, 2024
1 parent e0b493f commit d4de9e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions source/MaaWin32ControlUnit/Manager/ControlUnitMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ bool ControlUnitMgr::find_device(std::vector<std::string>& devices)

bool ControlUnitMgr::connect()
{
if (!hwnd_) {
LogError << "hwnd_ is nullptr";
return false;
}
if (hwnd_) {
if (!IsWindow(hwnd_)) {
LogError << "hwnd_ is invalid";
return false;
}

if (!IsWindow(hwnd_)) {
LogError << "hwnd_ is invalid";
return false;
if (IsIconic(hwnd_)) {
LogError << "hwnd_ is minimized";
return false;
}
}

if (IsIconic(hwnd_)) {
LogError << "hwnd_ is minimized";
return false;
else {
LogWarn << "hwnd_ is nullptr";
}

if (screencap_method_ != MaaWin32ScreencapMethod_None) {
Expand All @@ -60,8 +60,7 @@ bool ControlUnitMgr::connect()
bool ControlUnitMgr::request_uuid(std::string& uuid)
{
if (!hwnd_) {
LogError << "hwnd_ is nullptr";
return false;
LogWarn << "hwnd_ is nullptr";
}

std::stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion source/binding/Python/maa/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class Win32Controller(Controller):

def __init__(
self,
hWnd: ctypes.c_void_p,
hWnd: Optional[ctypes.c_void_p],
screencap_method: int = MaaWin32ScreencapMethodEnum.DXGI_DesktopDup,
input_method: int = MaaWin32InputMethodEnum.Seize,
notification_handler: Optional[NotificationHandler] = None,
Expand Down

0 comments on commit d4de9e9

Please sign in to comment.