| 105 | } |
| 106 | |
| 107 | MaaController* create_win32_controller() |
| 108 | { |
| 109 | void* hwnd = nullptr; // It's a HWND, you can find it by yourself without MaaToolkit API |
| 110 | |
| 111 | auto list_handle = MaaToolkitDesktopWindowListCreate(); |
| 112 | auto destroy = [&]() { |
| 113 | MaaToolkitDesktopWindowListDestroy(list_handle); |
| 114 | }; |
| 115 | |
| 116 | MaaToolkitDesktopWindowFindAll(list_handle); |
| 117 | |
| 118 | size_t size = MaaToolkitDesktopWindowListSize(list_handle); |
| 119 | |
| 120 | if (size == 0) { |
| 121 | std::cout << "No window found" << std::endl; |
| 122 | |
| 123 | destroy(); |
| 124 | return nullptr; |
| 125 | } |
| 126 | |
| 127 | for (size_t i = 0; i < size; ++i) { |
| 128 | auto window_handle = MaaToolkitDesktopWindowListAt(list_handle, i); |
| 129 | std::string class_name = MaaToolkitDesktopWindowGetClassName(window_handle); |
| 130 | std::string window_name = MaaToolkitDesktopWindowGetWindowName(window_handle); |
| 131 | |
| 132 | if (window_name.find("二重螺旋") != std::string::npos) { |
| 133 | hwnd = MaaToolkitDesktopWindowGetHandle(window_handle); |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // create controller by hwnd |
| 139 | auto controller_handle = MaaWin32ControllerCreate( |
| 140 | hwnd, |
| 141 | MaaWin32ScreencapMethod_DXGI_DesktopDup_Window, |
| 142 | MaaWin32InputMethod_SendMessage, |
| 143 | MaaWin32InputMethod_SendMessage); |
| 144 | |
| 145 | destroy(); |
| 146 | return controller_handle; |
| 147 | } |
| 148 | |
| 149 | MaaController* create_macos_controller() |
| 150 | { |
nothing calls this directly
no test coverage detected