#include "InfrastAbstractTask.h" #include #include #include "WinMacro.h" #include "Identify.h" #include "Configer.h" #include "InfrastConfiger.h" #include "Logger.hpp" using namespace asst; asst::InfrastAbstractTask::InfrastAbstractTask(AsstCallback callback, void* callback_arg) : OcrAbstractTask(callback, callback_arg), m_swipe_begin(Configer::WindowWidthDefault * 0.9, Configer::WindowHeightDefault * 0.5, 0, 0), m_swipe_end(Configer::WindowWidthDefault * 0.5, Configer::WindowHeightDefault * 0.5, 0, 0) { } bool asst::InfrastAbstractTask::swipe_to_the_left() { DebugTraceFunction; constexpr int SwipeTimes = 5; m_swipe_duration = 100; m_swipe_extra_delay = 0; // 往左使劲滑几下 bool ret = false; for (int i = 0; i != SwipeTimes; ++i) { ret = swipe(true); if (!ret) { break; } } m_swipe_duration = SwipeDurationDefault; m_swipe_extra_delay = SwipeExtraDelayDefault; sleep(SwipeExtraDelayDefault); return ret; } bool asst::InfrastAbstractTask::click_clear_button() { DebugTraceFunction; const static Rect ClearButtonRect(430, 655, 150, 40); return m_controller_ptr->click(ClearButtonRect); } bool asst::InfrastAbstractTask::click_confirm_button() { DebugTraceFunction; const static Rect ConfirmButtonRect(1105, 655, 150, 40); return m_controller_ptr->click(ConfirmButtonRect); } bool asst::InfrastAbstractTask::click_return_button() { DebugTraceFunction; const static Rect ConfirmButtonRect(20, 20, 135, 35); return m_controller_ptr->click(ConfirmButtonRect); } bool asst::InfrastAbstractTask::swipe(bool reverse) { DebugTraceFunction; //#ifndef LOG_TRACE bool ret = true; if (!reverse) { ret &= m_controller_ptr->swipe(m_swipe_begin, m_swipe_end, m_swipe_duration); ++m_swipe_times; } else { ret &= m_controller_ptr->swipe(m_swipe_end, m_swipe_begin, m_swipe_duration); --m_swipe_times; } ret &= sleep(m_swipe_extra_delay); return ret; //#else // return sleep(SwipeExtraDelay); //#endif } bool asst::InfrastAbstractTask::swipe_left() { const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); const static Rect left_rect(Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); return m_controller_ptr->swipe(left_rect, right_rect); } bool asst::InfrastAbstractTask::swipe_right() { const static Rect right_rect(Configer::WindowWidthDefault * 0.8, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); const static Rect left_rect(Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.1, Configer::WindowHeightDefault * 0.2); return m_controller_ptr->swipe(right_rect, left_rect); } std::vector