Skip to content

Commit

Permalink
to resolve merge conflict between main and build branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hetulbhatt committed Aug 28, 2023
2 parents beb13c8 + c2c03bf commit c84065b
Show file tree
Hide file tree
Showing 20 changed files with 1,053 additions and 889 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,24 @@ jobs:
- name: Set up environment
run: echo "Running on Windows - ${{ matrix.architecture }}"

- name: Install MSVC
uses: microsoft/setup-msbuild@v1
- uses: ilammy/msvc-dev-cmd@v1

# - name: Set up MSVC environment
# shell: cmd
# run: |
# call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

- name: Build
run: cl /EHsc /I.\include /Fe:KeyFlow-${{ matrix.architecture }}.exe src\main.cpp user32.lib
run: cl /EHsc KeyFlow\KeyFlow.cpp /link user32.lib /Fe:KeyFlow.exe

- name: Display structure of downloaded files
run: tree /f /a ..

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: KeyFlow-windows-${{ matrix.architecture }}-executable
path: KeyFlow-${{ matrix.architecture }}.exe
path: KeyFlow.exe

create_release:
needs: build
Expand All @@ -54,12 +61,12 @@ jobs:
path: workspace

- name: Display structure of downloaded files
run: tree .
run: tree /f /a ..

- name: Determine Alpha Version
id: determine_alpha_version
run: |
echo "::set-output name=ALPHA_VERSION::alpha.$(date +%Y%m%d).${{ github.run_number }}"
echo "::set-output name=ALPHA_VERSION::alpha.$(date +%Y%m%d).${{ github.run_number }}.msvc"
- name: Create Release
id: create_release
Expand All @@ -80,7 +87,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: workspace/KeyFlow-windows-x86-executable/KeyFlow-x86.exe
asset_path: workspace/KeyFlow-windows-x86-executable/KeyFlow.exe
asset_name: KeyFlow-x86.exe
asset_content_type: application/octet-stream

Expand All @@ -90,7 +97,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: workspace/KeyFlow-windows-x64-executable/KeyFlow-x64.exe
asset_path: workspace/KeyFlow-windows-x64-executable/KeyFlow.exe
asset_name: KeyFlow-x64.exe
asset_content_type: application/octet-stream

Expand All @@ -100,7 +107,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: workspace/KeyFlow-windows-ARM-executable/KeyFlow-ARM.exe
asset_path: workspace/KeyFlow-windows-ARM-executable/KeyFlow.exe
asset_name: KeyFlow-ARM.exe
asset_content_type: application/octet-stream

Expand All @@ -110,6 +117,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: workspace/KeyFlow-windows-ARM64-executable/KeyFlow-ARM64.exe
asset_path: workspace/KeyFlow-windows-ARM64-executable/KeyFlow.exe
asset_name: KeyFlow-ARM64.exe
asset_content_type: application/octet-stream
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
build/*
src/*
!src/main.cpp
.vs
x64
KeyFlow/KeyFlow.vcxproj.user
KeyFlow/x64
KeyFlow/logs
18 changes: 18 additions & 0 deletions KeyFlow/KeyFlow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "keyhook.hpp"

int main(int argc, char* argv[]) {
Logger::initialize();
Logger::log("OK!\n\n");
KeyHook& keyHook = KeyHookSingleton::getInstance();
FileLoader& fileLoader = keyHook.getKeystrokeHandler().getFileLoader();
if (argc == 3) {
fileLoader.loadFromFiles(argv[1], argv[2]);
}
else {
fileLoader.loadFromFiles();
}
keyHook.getKeystrokeHandler().resizeBuffer(fileLoader.getCodeLength());
keyHook.setup_hook();
Logger::shutdown();
return 0;
}
146 changes: 146 additions & 0 deletions KeyFlow/KeyFlow.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4b2f9e24-8657-49a8-adca-f94e0194b4b2}</ProjectGuid>
<RootNamespace>KeyFlow</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="KeyFlow.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="action_performer.hpp" />
<ClInclude Include="fileloader.hpp" />
<ClInclude Include="helper.hpp" />
<ClInclude Include="keyhook.hpp" />
<ClInclude Include="keystroke_handler.hpp" />
<ClInclude Include="logger.hpp" />
<ClInclude Include="systemtraymanager.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
76 changes: 76 additions & 0 deletions KeyFlow/action_performer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#pragma once
#ifndef ACTION_PERFORMER_H
#define ACTION_PERFORMER_H

#include <windows.h>
#include <string>
#include <iostream>

#include "logger.hpp"

class ActionPerformer
{
public:
ActionPerformer()
{
Logger::log("ActionPerformer()\n");
}

void simulate_paste(const std::string& stringToPaste)
{
// Get the handle of the active window
HWND activeWindow = GetForegroundWindow();

// Set the active window as the foreground window
SetForegroundWindow(activeWindow);

// Set up the datastructure
INPUT* inputs = new INPUT[stringToPaste.length() * 2];
memset(inputs, 0, stringToPaste.length() * 2 * sizeof(INPUT));

for (size_t i = 0; i < stringToPaste.length(); i++)
{
// Set up the INPUT structure for the character
inputs[i * 2].type = INPUT_KEYBOARD;
inputs[i * 2].ki.dwFlags = KEYEVENTF_UNICODE;
inputs[i * 2].ki.wScan = stringToPaste[i];

inputs[i * 2 + 1].type = INPUT_KEYBOARD;
inputs[i * 2 + 1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
inputs[i * 2 + 1].ki.wScan = stringToPaste[i];
}

// Send the input events to the active window
SendInput(stringToPaste.length() * 2, inputs, sizeof(INPUT));

delete[] inputs;
}

void execute_program(const std::string& path)
{
STARTUPINFOA startupInfo;
PROCESS_INFORMATION processInfo;

ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);

ZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION));

if (!CreateProcessA(NULL, const_cast<char*>(path.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
{
std::cerr << "Failed to create process: " << GetLastError() << std::endl;
return;
}

// // Wait for the process to finish
// WaitForSingleObject(pi.hProcess, INFINITE);

// Close process and thread handles
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);

Logger::log("Process execution completed for: " + path + "\n");
}
};

#endif
Loading

0 comments on commit c84065b

Please sign in to comment.