lolautoaccept/src/main.cpp
2022-03-01 18:32:43 +01:00

57 lines
1.2 KiB
C++

#include "Log.h"
#include "screen.h"
#include "matcher.h"
#include <xinputsimulator.h>
#include <thread>
int main(int argc, const char** argv) {
Log::init();
Log::setConsoleLogLevel(Log::Level::TRACE);
Log::addLogfile("log.txt", Log::Level::TRACE);
#if __unix__
Log::setColoredOutput(true);
#endif
Log::info << "Hello, World!";
// load template
Matcher matcher("imgs/Accept.png");
ScreenShot screen;
XInputSimulator& sim = XInputSimulator::getInstance();
while(true) {
cv::Mat img;
screen(img);
Matcher::Match mat = matcher.match(img);
Log::warn << "matched: " << mat.doesMatch;
if(mat.doesMatch) {
cv::rectangle(img, cv::Point(mat.x, mat.y), cv::Point( mat.x + mat.width , mat.y + mat.height ), cv::Scalar(0, 0, 255, 0), 2);
time_t t = time(0);
cv::imwrite("debugimages/" + std::to_string(t) + ".jpg", img);
int x = mat.x + (mat.width/2);
int y = mat.y + (mat.height/2);
sim.mouseMoveTo(x, y);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
sim.mouseClick(XIS::LEFT_MOUSE_BUTTON);
std::this_thread::sleep_for(std::chrono::seconds(10));
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
Log::stop();
return 0;
}