From 92a531b43a0a99ade2ed40fef2d006ca9d7f0d99 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 13 Jul 2021 23:10:32 +0800 Subject: [PATCH] add show and hide window function --- MeoAssistance/include/WinMacro.h | 2 ++ MeoAssistance/src/Assistance.cpp | 2 ++ MeoAssistance/src/WinMacro.cpp | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/MeoAssistance/include/WinMacro.h b/MeoAssistance/include/WinMacro.h index 4ac76e40f4..1582106dcb 100644 --- a/MeoAssistance/include/WinMacro.h +++ b/MeoAssistance/include/WinMacro.h @@ -17,6 +17,8 @@ namespace asst { bool captured() const noexcept; bool resizeWindow(int Width, int Height); bool resizeWindow(); // by configer + bool showWindow(); + bool hideWindow(); bool click(const Point & p); bool clickRange(const Rect & rect); cv::Mat getImage(const Rect& rect); diff --git a/MeoAssistance/src/Assistance.cpp b/MeoAssistance/src/Assistance.cpp index bdb9ca9724..4313569e17 100644 --- a/MeoAssistance/src/Assistance.cpp +++ b/MeoAssistance/src/Assistance.cpp @@ -22,6 +22,8 @@ Assistance::Assistance() Assistance::~Assistance() { + m_pWindow->showWindow(); + m_thread_exit = true; m_thread_running = false; m_condvar.notify_one(); diff --git a/MeoAssistance/src/WinMacro.cpp b/MeoAssistance/src/WinMacro.cpp index 625f5d387d..2ce35bd47a 100644 --- a/MeoAssistance/src/WinMacro.cpp +++ b/MeoAssistance/src/WinMacro.cpp @@ -93,6 +93,24 @@ bool WinMacro::resizeWindow() return resizeWindow(m_width, m_height); } +bool WinMacro::showWindow() +{ + if (m_handle_type != HandleType::Window) { + return false; + } + + return ::ShowWindow(m_handle, SW_SHOW); +} + +bool WinMacro::hideWindow() +{ + if (m_handle_type != HandleType::Window) { + return false; + } + + return ::ShowWindow(m_handle, SW_HIDE); +} + double WinMacro::getScreenScale() { static double scale = 0;