1 Star 1 Fork 0

fhqmwy/mouseStart

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CheckBoot.cpp 3.22 KB
一键复制 编辑 原始数据 按行查看 历史
fhqmwy 提交于 2024-06-11 17:47 . cv
#include "CheckBoot.h"
#include <random>
#include <string>
#include "Screenshot.h"
#include "Cv.h"
void CheckBoot::BagGunsCheck()
{
// 枪名
int name_x = 31;
int name_y = 0;
int name_width = 162;
int name_height = 32;
cv::Rect name(name_x, name_y, name_width, name_height);
// 枪口
int muzzle_x = 5;
int muzzle_y = 145;
int muzzle_width = 43;
int muzzle_height = 36;
cv::Rect muzzle(muzzle_x, muzzle_y, muzzle_width, muzzle_height);
// 握把
int grip_x = 107;
int grip_y = 145;
int grip_width = 43;
int grip_height = 36;
cv::Rect grip(grip_x, grip_y, grip_width, grip_height);
// 瞄准镜
int sight_x = 273;
int sight_y = 22;
int sight_width = 50;
int sight_height = 22;
cv::Rect sight(sight_x, sight_y, sight_width, sight_height);
// 枪托
int butt_x = 424;
int butt_y = 133;
int butt_width = 47;
int butt_height = 47;
cv::Rect butt(butt_x, butt_y, butt_width, butt_height);
// 截图枪械1区域图片
cv::Mat gun1 = screenshot.getScreenshot(1328, 93, 481, 192);
cv::Mat gun1Name = gun1(name);
cv::Mat gun1MuzzleImage = gun1(muzzle);
cv::Mat gun1GripImage = gun1(grip);
cv::Mat gun1SightImage = gun1(sight);
cv::Mat gun1ButtImage = gun1(butt);
// 找到对应枪械配置进行修改
// 截图枪械2区域图片
cv::Mat gun2 = screenshot.getScreenshot(1328, 299, 481, 192);
// 获取枪械2配件
cv::Mat gun2Name = gun2(name);
cv::Mat gun2MuzzleImage = gun2(muzzle);
cv::Mat gun2GripImage = gun2(grip);
cv::Mat gun2SightImage = gun2(sight);
cv::Mat gun2ButtImage = gun2(butt);
// 找到对应枪械配置进行修改
}
void CheckBoot::FireListener(Screenshot screenshot)
{
// 使用默认随机数引擎和分布函数来生成随机整数
//std::random_device rd; // 随机设备,用于获取种子
//std::mt19937 gen(rd()); // Mersenne Twister 19937 随机数引擎,使用随机设备生成种子
//std::uniform_int_distribution<int> dis(1, 100); // 均匀分布,范围为 [1, 100]
while (true)
{
// 检查姿势
cv::Vec3b posture1 = screenshot.getPixelColor(218, 1060);
cv::Vec3b posture2 = screenshot.getPixelColor(218, 1060);
cv::Vec3b posture3 = screenshot.getPixelColor(218, 1060);
// TODO: 判断姿势
this->posture.store(1);
// 检查子弹
cv::Vec3b hasBullet1 = screenshot.getPixelColor(218, 1060);
cv::Vec3b hasBullet2 = screenshot.getPixelColor(218, 1060);
// TODO: 判断子弹
this->hasBullet.store(2);
// 检查开火模式
cv::Vec3b fireMode1 = screenshot.getPixelColor(218, 1060);
cv::Vec3b fireMode2 = screenshot.getPixelColor(218, 1060);
cv::Vec3b fireMode3 = screenshot.getPixelColor(218, 1060);
// TODO: 判断开火模式
this->fireMode.store(3);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
}
bool CheckBoot::BagListener(Screenshot screenshot)
{
cv::Mat bagFlag = screenshot.getScreenshotPart(11, 1, 1, 1);
// TODO 判断是否打开背包界面
return false;
}
bool CheckBoot::ActiveWindowListener()
{
HWND foregroundWindow = GetForegroundWindow();
if (foregroundWindow != NULL) {
std::wstring expectedTitle = L"绝地求生";
wchar_t windowTitle[256];
GetWindowText(foregroundWindow, windowTitle, sizeof(windowTitle));
if (std::wstring(windowTitle) == expectedTitle) {
return true;
}
}
return false;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/fhqmwy/mouse-start.git
git@gitee.com:fhqmwy/mouse-start.git
fhqmwy
mouse-start
mouseStart
master

搜索帮助