add create directories

add create directories
This commit is contained in:
Vladimir Golubev 2023-03-31 23:43:04 +03:00
parent 615e731a1d
commit fcfc8c2080
6 changed files with 19 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include <Dwmapi.h>
#include <iostream>
#include <fstream>
#include <filesystem>
#pragma comment(lib, "dwmapi.lib")
#pragma warning(disable : 4996)
#pragma once

View File

@ -3,3 +3,6 @@
const MARGINS margins = { -1 ,-1, -1, -1 };
const char g_szClassName[] = "overlay";
bool isVisible = true;
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);

View File

@ -133,10 +133,10 @@
<ItemGroup>
<ClInclude Include="functions\addWatermark.h" />
<ClInclude Include="functions\captureScreen.h" />
<ClInclude Include="functions\screenRecoder.h" />
<ClInclude Include="functions\screenRecorder.h" />
<ClInclude Include="Include\Include.h" />
<ClInclude Include="Include\Options.h" />
<ClInclude Include="Include\Overlay.h" />
<ClInclude Include="Include\stdafx.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -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);

View File

@ -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());
}

View File

@ -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);