From fcfc8c208055985c2e48f670171f79d5f50b1eb7 Mon Sep 17 00:00:00 2001 From: vosrhd9 Date: Fri, 31 Mar 2023 23:43:04 +0300 Subject: [PATCH] add create directories add create directories --- Overlay/Include/Include.h | 1 + Overlay/Include/Options.h | 5 ++++- Overlay/Overlay.vcxproj | 4 ++-- Overlay/functions/captureScreen.h | 2 +- Overlay/functions/screenRecorder.h | 2 +- Overlay/main.cpp | 11 ++++++++++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Overlay/Include/Include.h b/Overlay/Include/Include.h index 7eda8f6..cb5859b 100644 --- a/Overlay/Include/Include.h +++ b/Overlay/Include/Include.h @@ -3,6 +3,7 @@ #include #include #include +#include #pragma comment(lib, "dwmapi.lib") #pragma warning(disable : 4996) #pragma once \ No newline at end of file diff --git a/Overlay/Include/Options.h b/Overlay/Include/Options.h index aaeb3a4..4557a8a 100644 --- a/Overlay/Include/Options.h +++ b/Overlay/Include/Options.h @@ -2,4 +2,7 @@ #include "Include.h" const MARGINS margins = { -1 ,-1, -1, -1 }; const char g_szClassName[] = "overlay"; -bool isVisible = true; \ No newline at end of file +bool isVisible = true; + +int screenWidth = GetSystemMetrics(SM_CXSCREEN); +int screenHeight = GetSystemMetrics(SM_CYSCREEN); \ No newline at end of file diff --git a/Overlay/Overlay.vcxproj b/Overlay/Overlay.vcxproj index 8349db5..5f432e9 100644 --- a/Overlay/Overlay.vcxproj +++ b/Overlay/Overlay.vcxproj @@ -133,10 +133,10 @@ - + - + diff --git a/Overlay/functions/captureScreen.h b/Overlay/functions/captureScreen.h index be08dde..d9865a5 100644 --- a/Overlay/functions/captureScreen.h +++ b/Overlay/functions/captureScreen.h @@ -28,7 +28,7 @@ void captureScreen(std::string file_screenshot) // Добавление ватермарки на контекст addWatermark(hdcScreen, hdcDIB, bmi); - hFile = CreateFile(("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\" + file_screenshot).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\screenshot\\" + file_screenshot).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); BITMAPFILEHEADER hdr = { }; hdr.bfType = 0x4d42; // Буквы 'B' и 'M' hdr.bfOffBits = sizeof(hdr) + sizeof(BITMAPINFOHEADER); diff --git a/Overlay/functions/screenRecorder.h b/Overlay/functions/screenRecorder.h index f9fad0c..29ba76e 100644 --- a/Overlay/functions/screenRecorder.h +++ b/Overlay/functions/screenRecorder.h @@ -3,6 +3,6 @@ void screenRecorder(std::string file_video) { - std::string command = "ffmpeg -f gdigrab -framerate 60 -i desktop -c:v libx264 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p " + ("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\" + file_video); + std::string command = "ffmpeg -f gdigrab -framerate 60 -i desktop -c:v libx264 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p " + ("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\video\\" + file_video); system(command.c_str()); } \ No newline at end of file diff --git a/Overlay/main.cpp b/Overlay/main.cpp index bd3c82d..c648204 100644 --- a/Overlay/main.cpp +++ b/Overlay/main.cpp @@ -2,6 +2,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + std::string folder_path = "C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\"; + if (!std::filesystem::exists(folder_path)) { + std::filesystem::create_directories(folder_path); + std::filesystem::create_directories(folder_path + "video"); + std::filesystem::create_directories(folder_path + "screenshot"); + } + std::string file_screenshot = "screenshot_" + std::to_string(time(NULL)) + ".bmp"; std::string file_video = "video_" + std::to_string(time(NULL)) + ".mp4"; @@ -80,9 +87,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_szClassName, g_szClassName, WS_POPUP | WS_VISIBLE, - 0, 0, 1920, 1080, + 0, 0, screenWidth, screenHeight, NULL, NULL, hInstance, NULL); + SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 255, LWA_ALPHA); DwmExtendFrameIntoClientArea(hwnd, &margins); @@ -91,6 +99,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine RegisterHotKey(hwnd, 3, MOD_ALT, 0x50); RegisterHotKey(hwnd, 4, MOD_ALT, 0x56); + while (GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg);