mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-14 00:40:27 +08:00
Compare commits
8 Commits
release.be
...
release.be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e05430ec0e | ||
|
|
0a081d4fa2 | ||
|
|
a6488f0ea6 | ||
|
|
8844d35c2e | ||
|
|
0534e35871 | ||
|
|
107d3af5c5 | ||
|
|
1e170e6c1a | ||
|
|
f3773d22c6 |
@@ -20,10 +20,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Assistance.h" />
|
||||
<ClInclude Include="include\AsstAux.h" />
|
||||
<ClInclude Include="include\AsstCaller.h" />
|
||||
<ClInclude Include="include\AsstDef.h" />
|
||||
<ClInclude Include="include\Configer.h" />
|
||||
<ClInclude Include="include\Identify.h" />
|
||||
<ClInclude Include="include\Logger.hpp" />
|
||||
<ClInclude Include="include\Updater.h" />
|
||||
<ClInclude Include="include\WinMacro.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
<ClInclude Include="include\Updater.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Logger.hpp">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\AsstAux.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Configer.cpp">
|
||||
|
||||
37
MeoAssistance/include/AsstAux.h
Normal file
37
MeoAssistance/include/AsstAux.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
namespace asst {
|
||||
|
||||
static std::string GetCurrentDir()
|
||||
{
|
||||
static std::string cur_dir;
|
||||
if (cur_dir.empty()) {
|
||||
char exepath_buff[_MAX_PATH] = { 0 };
|
||||
::GetModuleFileNameA(NULL, exepath_buff, _MAX_PATH);
|
||||
std::string exepath(exepath_buff);
|
||||
cur_dir = exepath.substr(0, exepath.find_last_of('\\') + 1);
|
||||
}
|
||||
return cur_dir;
|
||||
}
|
||||
|
||||
static std::string GetResourceDir()
|
||||
{
|
||||
static std::string res_dir = GetCurrentDir() + "resource\\";
|
||||
return res_dir;
|
||||
}
|
||||
|
||||
static std::string StringReplaceAll(const std::string& src, const std::string& old_value, const std::string& new_value)
|
||||
{
|
||||
std::string str = src;
|
||||
for (std::string::size_type pos(0); pos != std::string::npos; pos += new_value.length()) {
|
||||
if ((pos = str.find(old_value, pos)) != std::string::npos)
|
||||
str.replace(pos, old_value.length(), new_value);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <chrono>
|
||||
#include <process.h>
|
||||
#include <Windows.h>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
namespace asst {
|
||||
|
||||
const static std::string Version = "release.beta.01.2";
|
||||
|
||||
/************ Type ************/
|
||||
const static std::string Version = "release.beta.02";
|
||||
|
||||
enum class HandleType
|
||||
{
|
||||
@@ -22,6 +16,43 @@ namespace asst {
|
||||
Control = 4
|
||||
};
|
||||
|
||||
static std::ostream& operator<<(std::ostream& os, const HandleType& type)
|
||||
{
|
||||
static std::unordered_map<HandleType, std::string> _type_name = {
|
||||
{HandleType::Window, "Window"},
|
||||
{HandleType::View, "View"},
|
||||
{HandleType::Control, "Control"}
|
||||
};
|
||||
return os << _type_name.at(type);
|
||||
}
|
||||
|
||||
enum class TaskType {
|
||||
Invalid = 0,
|
||||
BasicClick = 1,
|
||||
DoNothing = 2,
|
||||
Stop = 4,
|
||||
ClickSelf = 8 | BasicClick,
|
||||
ClickRect = 16 | BasicClick,
|
||||
ClickRand = 32 | BasicClick
|
||||
};
|
||||
static bool operator&(const TaskType& lhs, const TaskType& rhs)
|
||||
{
|
||||
return static_cast<std::underlying_type<TaskType>::type>(lhs) & static_cast<std::underlying_type<TaskType>::type>(rhs);
|
||||
}
|
||||
static std::ostream& operator<<(std::ostream& os, const TaskType& task)
|
||||
{
|
||||
static std::unordered_map<TaskType, std::string> _type_name = {
|
||||
{TaskType::Invalid, "Invalid"},
|
||||
{TaskType::BasicClick, "BasicClick"},
|
||||
{TaskType::ClickSelf, "ClickSelf"},
|
||||
{TaskType::ClickRect, "ClickRect"},
|
||||
{TaskType::ClickRand, "ClickRand"},
|
||||
{TaskType::DoNothing, "DoNothing"},
|
||||
{TaskType::Stop, "Stop"}
|
||||
};
|
||||
return os << _type_name.at(task);
|
||||
}
|
||||
|
||||
struct Point
|
||||
{
|
||||
Point() = default;
|
||||
@@ -39,7 +70,7 @@ namespace asst {
|
||||
{
|
||||
return { x, y, static_cast<int>(width * rhs), static_cast<int>(height * rhs) };
|
||||
}
|
||||
Rect center_zoom(double scale)
|
||||
Rect center_zoom(double scale) const
|
||||
{
|
||||
int half_width_scale = static_cast<int>(width * (1 - scale) / 2);
|
||||
int half_hight_scale = static_cast<int>(height * (1 - scale) / 2);
|
||||
@@ -51,111 +82,48 @@ namespace asst {
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
/************ Static Function ************/
|
||||
|
||||
static std::string GetCurrentDir()
|
||||
{
|
||||
static std::string cur_dir;
|
||||
if (cur_dir.empty()) {
|
||||
char exepath_buff[_MAX_PATH] = { 0 };
|
||||
::GetModuleFileNameA(NULL, exepath_buff, _MAX_PATH);
|
||||
std::string exepath(exepath_buff);
|
||||
cur_dir = exepath.substr(0, exepath.find_last_of('\\') + 1);
|
||||
}
|
||||
return cur_dir;
|
||||
}
|
||||
static std::string GetResourceDir()
|
||||
{
|
||||
static std::string res_dir = GetCurrentDir() + "resource\\";
|
||||
return res_dir;
|
||||
}
|
||||
|
||||
static std::string replace_all_distinct(const std::string& src, const std::string& old_value, const std::string& new_value)
|
||||
{
|
||||
std::string str = src;
|
||||
for (std::string::size_type pos(0); pos != std::string::npos; pos += new_value.length()) {
|
||||
if ((pos = str.find(old_value, pos)) != std::string::npos)
|
||||
str.replace(pos, old_value.length(), new_value);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/************ Print and Log Trace ************/
|
||||
|
||||
inline void StreamArgs(std::ostream& os)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
template <typename T, typename... Args>
|
||||
inline void StreamArgs(std::ostream& os, T&& first, Args && ...rest)
|
||||
{
|
||||
os << first << " ";
|
||||
StreamArgs(os, std::forward<Args>(rest)...);
|
||||
}
|
||||
template <typename... Args>
|
||||
void DebugPrint(const std::string& level, Args &&... args)
|
||||
{
|
||||
static std::mutex trace_mutex;
|
||||
std::unique_lock<std::mutex> trace_lock(trace_mutex);
|
||||
|
||||
SYSTEMTIME curtime;
|
||||
GetLocalTime(&curtime);
|
||||
char buff[64] = { 0 };
|
||||
sprintf_s(buff, "[%04d-%02d-%02d %02d:%02d:%02d.%03d][%s][Px%x][Tx%x]",
|
||||
curtime.wYear, curtime.wMonth, curtime.wDay,
|
||||
curtime.wHour, curtime.wMinute, curtime.wSecond, curtime.wMilliseconds,
|
||||
level.c_str(), _getpid(), GetCurrentThreadId());
|
||||
|
||||
if (level == "ERR" || level == "INF"
|
||||
#ifdef _DEBUG
|
||||
|| level == "TRC"
|
||||
#endif
|
||||
) {
|
||||
StreamArgs(std::cout, buff, std::forward<Args>(args)...);
|
||||
}
|
||||
std::ofstream out_stream(GetCurrentDir() + "asst.log", std::ios::out | std::ios::app);
|
||||
StreamArgs(out_stream, buff, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void DebugTrace(Args &&... args)
|
||||
{
|
||||
//#ifdef _DEBUG
|
||||
DebugPrint("TRC", std::forward<Args>(args)...);
|
||||
//#endif
|
||||
}
|
||||
template <typename... Args>
|
||||
inline void DebugTraceInfo(Args &&... args)
|
||||
{
|
||||
DebugPrint("INF", std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename... Args>
|
||||
inline void DebugTraceError(Args &&... args)
|
||||
{
|
||||
DebugPrint("ERR", std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
class DebugTraceFuncAux {
|
||||
public:
|
||||
DebugTraceFuncAux(const std::string& func_name)
|
||||
: m_func_name(func_name),
|
||||
m_start_time(std::chrono::system_clock::now())
|
||||
{
|
||||
DebugTrace(m_func_name, " | enter");
|
||||
}
|
||||
~DebugTraceFuncAux()
|
||||
{
|
||||
auto duration = std::chrono::system_clock::now() - m_start_time;
|
||||
DebugTrace(m_func_name, " | leave,",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(duration).count(), "ms");
|
||||
}
|
||||
private:
|
||||
std::string m_func_name;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
||||
struct HandleInfo {
|
||||
std::string className;
|
||||
std::string windowName;
|
||||
};
|
||||
|
||||
#define DebugTraceFunction DebugTraceFuncAux _func_aux(__FUNCTION__)
|
||||
struct AdbCmd {
|
||||
std::string path;
|
||||
std::string connect;
|
||||
std::string click;
|
||||
};
|
||||
|
||||
struct SimulatorInfo {
|
||||
std::vector<HandleInfo> window;
|
||||
std::vector<HandleInfo> view;
|
||||
std::vector<HandleInfo> control;
|
||||
bool is_adb = false;
|
||||
AdbCmd adb;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int x_offset = 0;
|
||||
int y_offset = 0;
|
||||
};
|
||||
|
||||
struct TaskInfo {
|
||||
std::string filename;
|
||||
double threshold = 0;
|
||||
double cache_threshold = 0;
|
||||
TaskType type = TaskType::Invalid;
|
||||
std::vector<std::string> next;
|
||||
int exec_times = 0;
|
||||
int max_times = INT_MAX;
|
||||
std::vector<std::string> exceeded_next;
|
||||
std::vector<std::string> reduce_other_times;
|
||||
asst::Rect specific_area;
|
||||
int pre_delay = 0;
|
||||
int rear_delay = 0;
|
||||
};
|
||||
|
||||
struct Options {
|
||||
int identify_delay = 0;
|
||||
bool identify_cache = false;
|
||||
int control_delay_lower = 0;
|
||||
int control_delay_upper = 0;
|
||||
};
|
||||
}
|
||||
@@ -8,54 +8,6 @@
|
||||
#include "AsstDef.h"
|
||||
|
||||
namespace asst {
|
||||
struct HandleInfo {
|
||||
std::string className;
|
||||
std::string windowName;
|
||||
};
|
||||
struct AdbCmd {
|
||||
std::string path;
|
||||
std::string connect;
|
||||
std::string click;
|
||||
};
|
||||
struct SimulatorInfo {
|
||||
std::vector<HandleInfo> window;
|
||||
std::vector<HandleInfo> view;
|
||||
std::vector<HandleInfo> control;
|
||||
bool is_adb = false;
|
||||
AdbCmd adb;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int x_offset = 0;
|
||||
int y_offset = 0;
|
||||
};
|
||||
|
||||
enum class TaskType {
|
||||
ClickSelf,
|
||||
ClickRand,
|
||||
DoNothing,
|
||||
Stop,
|
||||
ClickRect
|
||||
};
|
||||
|
||||
struct TaskInfo {
|
||||
std::string filename;
|
||||
double threshold = 0;
|
||||
double cache_threshold = 0;
|
||||
TaskType type;
|
||||
std::vector<std::string> next;
|
||||
int exec_times = 0;
|
||||
int max_times = INT_MAX;
|
||||
std::vector<std::string> exceeded_next;
|
||||
std::vector<std::string> reduce_other_times;
|
||||
asst::Rect specific_area;
|
||||
int pre_delay = 0;
|
||||
int rear_delay = 0;
|
||||
};
|
||||
struct Options {
|
||||
std::string delayType;
|
||||
int delayFixedTime = 0;
|
||||
bool cache = false;
|
||||
};
|
||||
|
||||
class Configer
|
||||
{
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "AsstDef.h"
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <tuple>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "AsstDef.h"
|
||||
|
||||
|
||||
namespace asst {
|
||||
|
||||
|
||||
105
MeoAssistance/include/Logger.hpp
Normal file
105
MeoAssistance/include/Logger.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
#include "AsstAux.h"
|
||||
|
||||
namespace asst {
|
||||
class Logger {
|
||||
public:
|
||||
~Logger() = default;
|
||||
|
||||
Logger(const Logger&) = delete;
|
||||
Logger(Logger&&) = delete;
|
||||
|
||||
static Logger& get_instance()
|
||||
{
|
||||
static Logger _unique_instance;
|
||||
return _unique_instance;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void log_trace(Args &&... args)
|
||||
{
|
||||
log("TRC", std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename... Args>
|
||||
inline void log_info(Args &&... args)
|
||||
{
|
||||
log("INF", std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename... Args>
|
||||
inline void log_error(Args &&... args)
|
||||
{
|
||||
log("ERR", std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
Logger() = default;
|
||||
|
||||
template <typename... Args>
|
||||
void log(const std::string& level, Args &&... args)
|
||||
{
|
||||
std::unique_lock<std::mutex> trace_lock(m_trace_mutex);
|
||||
|
||||
SYSTEMTIME curtime;
|
||||
GetLocalTime(&curtime);
|
||||
char buff[64] = { 0 };
|
||||
sprintf_s(buff, "[%04d-%02d-%02d %02d:%02d:%02d.%03d][%s][Px%x][Tx%x]",
|
||||
curtime.wYear, curtime.wMonth, curtime.wDay,
|
||||
curtime.wHour, curtime.wMinute, curtime.wSecond, curtime.wMilliseconds,
|
||||
level.c_str(), _getpid(), GetCurrentThreadId());
|
||||
|
||||
if (level == "ERR" || level == "INF"
|
||||
#ifdef _DEBUG
|
||||
|| level == "TRC"
|
||||
#endif
|
||||
) {
|
||||
stream_args(std::cout, buff, std::forward<Args>(args)...);
|
||||
}
|
||||
std::ofstream out_stream(asst::GetCurrentDir() + "asst.log", std::ios::out | std::ios::app);
|
||||
stream_args(out_stream, buff, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
inline void stream_args(std::ostream& os, T&& first, Args && ...rest)
|
||||
{
|
||||
os << first << " ";
|
||||
stream_args(os, std::forward<Args>(rest)...);
|
||||
}
|
||||
|
||||
inline void stream_args(std::ostream& os)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
std::mutex m_trace_mutex;
|
||||
};
|
||||
|
||||
class LoggerAux {
|
||||
public:
|
||||
LoggerAux(const std::string& func_name)
|
||||
: m_func_name(func_name),
|
||||
m_start_time(std::chrono::system_clock::now())
|
||||
{
|
||||
Logger::get_instance().log_trace(m_func_name, " | enter");
|
||||
}
|
||||
~LoggerAux()
|
||||
{
|
||||
auto duration = std::chrono::system_clock::now() - m_start_time;
|
||||
Logger::get_instance().log_trace(m_func_name, " | leave,",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(duration).count(), "ms");
|
||||
}
|
||||
private:
|
||||
std::string m_func_name;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
||||
};
|
||||
}
|
||||
|
||||
#define DebugTrace Logger::get_instance().log_trace
|
||||
#define DebugTraceInfo Logger::get_instance().log_info
|
||||
#define DebugTraceError Logger::get_instance().log_error
|
||||
#define DebugTraceFunction LoggerAux _func_aux(__FUNCTION__)
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <mutex>
|
||||
|
||||
namespace asst {
|
||||
struct __declspec(dllexport) VersionInfo {
|
||||
@@ -31,5 +32,6 @@ namespace asst {
|
||||
|
||||
bool m_has_new_version = false;
|
||||
VersionInfo m_lastest_version;
|
||||
std::mutex m_mutex;
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "WinMacro.h"
|
||||
#include "Configer.h"
|
||||
#include "Identify.h"
|
||||
#include "Logger.hpp"
|
||||
#include "AsstAux.h"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
@@ -17,7 +19,7 @@ Assistance::Assistance()
|
||||
{
|
||||
m_pIder->addImage(name, GetResourceDir() + info.filename);
|
||||
}
|
||||
m_pIder->setUseCache(Configer::m_options.cache);
|
||||
m_pIder->setUseCache(Configer::m_options.identify_cache);
|
||||
|
||||
m_working_thread = std::thread(workingProc, this);
|
||||
|
||||
@@ -84,6 +86,8 @@ std::optional<std::string> Assistance::setSimulator(const std::string& simulator
|
||||
void Assistance::start(const std::string& task)
|
||||
{
|
||||
DebugTraceFunction;
|
||||
DebugTrace("Start |", task);
|
||||
|
||||
|
||||
if (m_thread_running || !m_inited) {
|
||||
return;
|
||||
@@ -102,6 +106,7 @@ void Assistance::start(const std::string& task)
|
||||
void Assistance::stop(bool block)
|
||||
{
|
||||
DebugTraceFunction;
|
||||
DebugTrace("Stop |", block);
|
||||
|
||||
std::unique_lock<std::mutex> lock;
|
||||
if (block) { // Íⲿµ÷ÓÃ
|
||||
@@ -123,7 +128,7 @@ bool Assistance::setParam(const std::string& type, const std::string& param, con
|
||||
|
||||
std::optional<std::string> Assistance::getParam(const std::string& type, const std::string& param)
|
||||
{
|
||||
DebugTraceFunction;
|
||||
// DebugTraceFunction;
|
||||
|
||||
return Configer::getParam(type, param);
|
||||
}
|
||||
@@ -155,24 +160,33 @@ void Assistance::workingProc(Assistance* pThis)
|
||||
|
||||
if (!matched_task.empty()) {
|
||||
auto&& task = Configer::m_tasks[matched_task];
|
||||
DebugTraceInfo("***Matched***", matched_task, "Type:", static_cast<int>(task.type));
|
||||
DebugTraceInfo("***Matched***", matched_task, "Type:", task.type);
|
||||
if (task.pre_delay > 0) {
|
||||
DebugTrace("PreDelay", task.pre_delay);
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(task.pre_delay));
|
||||
auto cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(task.pre_delay),
|
||||
bool cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(task.pre_delay),
|
||||
[&]() -> bool { return !pThis->m_thread_running; });
|
||||
if (cv_ret == true) {
|
||||
continue;
|
||||
}
|
||||
if (cv_ret) { continue; }
|
||||
}
|
||||
|
||||
if (task.max_times != INT_MAX) {
|
||||
DebugTrace("CurTimes:", task.exec_times, "MaxTimes:", task.max_times);
|
||||
}
|
||||
if (task.exec_times < task.max_times) {
|
||||
if ((task.type & TaskType::BasicClick)
|
||||
&& Configer::m_options.control_delay_upper != 0) {
|
||||
static std::default_random_engine rand_engine(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
static std::uniform_int_distribution<unsigned> rand_uni(Configer::m_options.control_delay_lower, Configer::m_options.control_delay_upper);
|
||||
int delay = rand_uni(rand_engine);
|
||||
DebugTraceInfo("Random Delay", delay, "ms");
|
||||
bool cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(delay),
|
||||
[&]() -> bool { return !pThis->m_thread_running; });
|
||||
if (cv_ret) { continue; }
|
||||
}
|
||||
switch (task.type) {
|
||||
case TaskType::ClickRect:
|
||||
matched_rect = task.specific_area;
|
||||
[[fallthrough]];
|
||||
case TaskType::ClickSelf:
|
||||
pThis->m_pCtrl->clickRange(matched_rect);
|
||||
break;
|
||||
@@ -187,7 +201,7 @@ void Assistance::workingProc(Assistance* pThis)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
DebugTraceError("Unknown option type:", static_cast<int>(task.type));
|
||||
DebugTraceError("Unknown option type:", task.type);
|
||||
break;
|
||||
}
|
||||
++task.exec_times;
|
||||
@@ -200,9 +214,7 @@ void Assistance::workingProc(Assistance* pThis)
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(task.rear_delay));
|
||||
auto cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(task.rear_delay),
|
||||
[&]() -> bool { return !pThis->m_thread_running; });
|
||||
if (cv_ret == true) {
|
||||
continue;
|
||||
}
|
||||
if (cv_ret) { continue; }
|
||||
}
|
||||
pThis->m_next_tasks = Configer::m_tasks[matched_task].next;
|
||||
}
|
||||
@@ -221,7 +233,7 @@ void Assistance::workingProc(Assistance* pThis)
|
||||
DebugTrace("Next:", nexts_str);
|
||||
}
|
||||
pThis->m_condvar.wait_for(lock,
|
||||
std::chrono::milliseconds(Configer::m_options.delayFixedTime),
|
||||
std::chrono::milliseconds(Configer::m_options.identify_delay),
|
||||
[&]() -> bool { return !pThis->m_thread_running; });
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "json.h"
|
||||
#include "AsstDef.h"
|
||||
#include "AsstAux.h"
|
||||
#include "Logger.hpp"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
@@ -39,9 +41,10 @@ bool Configer::reload()
|
||||
m_version = root["version"].as_string();
|
||||
|
||||
auto options_obj = root["options"].as_object();
|
||||
m_options.delayType = options_obj["delay"]["type"].as_string();
|
||||
m_options.delayFixedTime = options_obj["delay"]["fixedTime"].as_integer();
|
||||
m_options.cache = options_obj["cache"].as_boolean();
|
||||
m_options.identify_delay = options_obj["identifyDelay"].as_integer();
|
||||
m_options.identify_cache = options_obj["identifyCache"].as_boolean();
|
||||
m_options.control_delay_lower = options_obj["controlDelayRange"][0].as_integer();
|
||||
m_options.control_delay_upper = options_obj["controlDelayRange"][1].as_integer();
|
||||
|
||||
auto tasks_obj = root["tasks"].as_object();
|
||||
for (auto&& [name, task_json] : tasks_obj) {
|
||||
@@ -148,7 +151,7 @@ bool Configer::reload()
|
||||
if (simulator_json.exist("adbControl")) {
|
||||
simulator_info.is_adb = true;
|
||||
// meojson的bug,暂时没空修,先转个字符串
|
||||
simulator_info.adb.path = replace_all_distinct(simulator_json["adbControl"]["path"].as_string(), "\\\\", "\\");
|
||||
simulator_info.adb.path = StringReplaceAll(simulator_json["adbControl"]["path"].as_string(), "\\\\", "\\");
|
||||
simulator_info.adb.connect = simulator_json["adbControl"]["connect"].as_string();
|
||||
simulator_info.adb.click = simulator_json["adbControl"]["click"].as_string();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "json.h"
|
||||
#include "AsstDef.h"
|
||||
#include "Logger.hpp"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
@@ -32,6 +33,8 @@ bool Updater::has_new_version()
|
||||
}
|
||||
|
||||
json::value root = std::move(parse_ret).value();
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
try {
|
||||
m_lastest_version.tag_name = root["tag_name"].as_string();
|
||||
m_lastest_version.html_url = root["html_url"].as_string();
|
||||
@@ -60,9 +63,6 @@ bool Updater::has_new_version()
|
||||
|
||||
const VersionInfo & Updater::get_version_info() const noexcept
|
||||
{
|
||||
if (!m_has_new_version) {
|
||||
return VersionInfo();
|
||||
}
|
||||
return m_lastest_version;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ std::optional<std::string> Updater::request_github_api()
|
||||
return std::nullopt;
|
||||
}
|
||||
std::string response;
|
||||
size_t buff_size = 4096;
|
||||
DWORD buff_size = 4096;
|
||||
char *buffer = new char[buff_size];
|
||||
DWORD number = 1;
|
||||
while (number > 0) {
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <WinUser.h>
|
||||
|
||||
#include "Configer.h"
|
||||
#include "AsstDef.h"
|
||||
#include "Logger.hpp"
|
||||
|
||||
using namespace asst;
|
||||
|
||||
WinMacro::WinMacro(const std::string& simulator_name, HandleType type)
|
||||
: m_simulator_name(simulator_name),
|
||||
m_handle_type(type),
|
||||
m_rand_engine(time(NULL))
|
||||
m_rand_engine(std::chrono::system_clock::now().time_since_epoch().count())
|
||||
{
|
||||
findHandle();
|
||||
}
|
||||
@@ -46,7 +47,7 @@ bool WinMacro::findHandle()
|
||||
handle_vec = info.control;
|
||||
break;
|
||||
default:
|
||||
DebugTraceError("Handle type error!", static_cast<int>(m_handle_type));
|
||||
DebugTraceError("Handle type error!", m_handle_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,14 +95,14 @@ bool WinMacro::findHandle()
|
||||
}
|
||||
size_t pos = adb_dir.find_last_of('\\') + 1;
|
||||
adb_dir = adb_dir.substr(0, pos);
|
||||
adb_dir = '"' + replace_all_distinct(info.adb.path, "[EmulatorPath]", adb_dir) + '"';
|
||||
adb_dir = '"' + StringReplaceAll(info.adb.path, "[EmulatorPath]", adb_dir) + '"';
|
||||
std::string connect_cmd = adb_dir + info.adb.connect;
|
||||
int ret = system(connect_cmd.c_str());
|
||||
DebugTrace("Call", connect_cmd, "—— ret", ret);
|
||||
|
||||
m_click_cmd = adb_dir + info.adb.click;
|
||||
}
|
||||
DebugTrace("Handle:", m_handle, "Name:", m_simulator_name, "Type:", static_cast<int>(m_handle_type));
|
||||
DebugTrace("Handle:", m_handle, "Name:", m_simulator_name, "Type:", m_handle_type);
|
||||
|
||||
if (m_handle != NULL) {
|
||||
return true;
|
||||
@@ -191,8 +192,8 @@ bool WinMacro::click(const Point& p)
|
||||
if (m_is_adb) {
|
||||
int x = (p.x + m_x_offset);
|
||||
int y = (p.y + m_y_offset);
|
||||
std::string cur_cmd = replace_all_distinct(m_click_cmd, "[x]", std::to_string(x));
|
||||
cur_cmd = replace_all_distinct(cur_cmd, "[y]", std::to_string(y));
|
||||
std::string cur_cmd = StringReplaceAll(m_click_cmd, "[x]", std::to_string(x));
|
||||
cur_cmd = StringReplaceAll(cur_cmd, "[y]", std::to_string(y));
|
||||
int ret = system(cur_cmd.c_str());
|
||||
DebugTrace("Call", cur_cmd, "—— ret", ret);
|
||||
return !ret;
|
||||
@@ -200,7 +201,7 @@ bool WinMacro::click(const Point& p)
|
||||
else {
|
||||
int x = (p.x + m_x_offset) / getScreenScale();
|
||||
int y = (p.y + m_y_offset) / getScreenScale();
|
||||
DebugTrace("Click, raw:", p.x, p.y, "cor:", x, y);
|
||||
DebugTrace("Click, raw:", p.x, p.y, "corr:", x, y);
|
||||
|
||||
LPARAM lparam = MAKELPARAM(x, y);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>0.1.0.0</ApplicationVersion>
|
||||
<ApplicationVersion>0.2.0.0</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
||||
27
README.md
27
README.md
@@ -4,20 +4,18 @@ A game assistance for Arknights
|
||||
|
||||
一款明日方舟的游戏辅助,供PC端安卓模拟器使用,龟速开发中……
|
||||
|
||||

|
||||

|
||||
|
||||
## 功能介绍
|
||||
|
||||
- 支持自动刷完理智
|
||||
- 支持自动吃完体力药
|
||||
- 支持根据设置自动吃石头
|
||||
- 刷完后程序会自动停止
|
||||
- 自动刷完理智
|
||||
- 可设置是否吃完理智药
|
||||
- 可设置是否吃石头级数量
|
||||
- 可设置刷的次数
|
||||
- 代理失败会自动放弃本次行动
|
||||
- 支持自动访问好友基建
|
||||
- 所有操作,都是点击按钮内随机位置,且模拟泊松分布,不会像鼠标宏一样一直是同一个点,没有封号风险
|
||||
~~(虽然好像也没听说过谁用鼠标宏被封号的)~~
|
||||
- 模拟器窗口可以被遮挡,即使全屏看视频、玩游戏,也完全不影响辅助运行
|
||||
~~(但是模拟器还是不能最小化)~~
|
||||
- 支持自动访问好友基建,访问完了还会贴心的帮你点进信用商店~
|
||||
- 所有操作,都是点击按钮内随机位置,且支持设置随机延时,没有封号风险
|
||||
- 模拟器窗口可以被遮挡,即使全屏看视频、玩游戏,也不影响辅助运行
|
||||
- 支持多款主流模拟器
|
||||
- 自适应分辨率及屏幕缩放
|
||||
- 未来更多功能见[Todo](#Todo)
|
||||
@@ -74,6 +72,12 @@ MuMu是个奇葩,它的所有的窗口句柄均不响应SendMessage鼠标消
|
||||
2. 点击"访问基建"
|
||||
3. 达到10次上限,或者所有可访问的好友都访问完了,就会自动停的
|
||||
|
||||
### 设置操作延时
|
||||
|
||||
请手动修改`resource\config.json`文件中,`options`.`controlDelayRange`字段的值,格式为`[最小延时, 最大延时]`,单位为毫秒,例如想设置3~5秒的随机延时,即设置为`[ 3000, 5000]` 即可。文件保存后请重新打开程序。
|
||||
|
||||

|
||||
|
||||
## Todo
|
||||
|
||||
~~在做了在做了.jpg~~
|
||||
@@ -83,7 +87,7 @@ MuMu是个奇葩,它的所有的窗口句柄均不响应SendMessage鼠标消
|
||||
- [x] 基本图形化界面
|
||||
- [ ] 图形化界面进一步完善
|
||||
- [ ] 日志打印,错误提示
|
||||
- [ ] 使模拟器窗口不可见的按钮
|
||||
- [ ] 操作随机延时支持设置
|
||||
- [ ] 刷理智
|
||||
- [x] 支持剿灭
|
||||
- [x] 支持使模拟器窗口不可见
|
||||
@@ -93,6 +97,7 @@ MuMu是个奇葩,它的所有的窗口句柄均不响应SendMessage鼠标消
|
||||
- [x] 支持自动勾选代理指挥
|
||||
- [x] 支持刷指定次数
|
||||
- [x] 自动吃石头(根据设置,指定数量)
|
||||
- [x] 操作随机延时
|
||||
- [ ] 指定刷XX个某材料
|
||||
- [ ] 支持凌晨4点更新数据
|
||||
- [ ] 结束界面自动截图,可用于上传企鹅物流
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Assistance.h"
|
||||
#include "Updater.h"
|
||||
#include "Logger.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
BIN
readme/controlDelayRange.png
Normal file
BIN
readme/controlDelayRange.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@@ -1,11 +1,9 @@
|
||||
{
|
||||
"version": "0.3",
|
||||
"version": "0.4",
|
||||
"options": {
|
||||
"delay": {
|
||||
"type": "fixedTime",
|
||||
"fixedTime": 1000
|
||||
},
|
||||
"cache": true
|
||||
"identifyCache": true,
|
||||
"identifyDelay": 1000,
|
||||
"controlDelayRange": [ 0, 0 ]
|
||||
},
|
||||
"handle": {
|
||||
"BlueStacks": {
|
||||
@@ -163,8 +161,8 @@
|
||||
],
|
||||
"control": [
|
||||
{
|
||||
"class": "Qt5QWindowIcon",
|
||||
"window": "明日方舟 - 星云引擎"
|
||||
"class": "Qt5QWindowIcon_DELETE",
|
||||
"window": "明日方舟 - 星云引擎_DELETE"
|
||||
}
|
||||
],
|
||||
"adbControl": {
|
||||
@@ -252,6 +250,7 @@
|
||||
"PRTS": {
|
||||
"filename": "PRTS.png",
|
||||
"type": "doNothing",
|
||||
"rearDelay": 5000,
|
||||
"next": [
|
||||
"PRTS",
|
||||
"PrtsErrorConfirm",
|
||||
@@ -372,7 +371,7 @@
|
||||
"VisitNext": {
|
||||
"filename": "VisitNext.png",
|
||||
"type": "clickSelf",
|
||||
"threshold": 0.999,
|
||||
"threshold": 0.99,
|
||||
"maxTimes": 21,
|
||||
"exceededNext": [
|
||||
"ReturnToMall"
|
||||
|
||||
Reference in New Issue
Block a user