Skip to content

Commit

Permalink
Refactored code once again
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Feb 15, 2021
1 parent e8eb542 commit 99eac48
Show file tree
Hide file tree
Showing 46 changed files with 46,084 additions and 33,439 deletions.
2 changes: 1 addition & 1 deletion clicker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BEC80A2B-E5C0-4326-8906-B0886AFC0B03}
SolutionGuid = {F8C9014A-8314-4361-8F32-237BA879F712}
EndGlobalSection
EndGlobal
65 changes: 40 additions & 25 deletions clicker.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,54 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="clicker\clicker.cpp" />
<ClCompile Include="def\include\console\console.cpp" />
<ClCompile Include="def\include\imgui\imgui.cpp" />
<ClCompile Include="def\include\imgui\imgui_draw.cpp" />
<ClCompile Include="def\include\imgui\imgui_widgets.cpp" />
<ClCompile Include="def\include\imgui\impl\imgui_impl_dx9.cpp" />
<ClCompile Include="def\include\imgui\impl\imgui_impl_win32.cpp" />
<ClCompile Include="def\config\config.cpp" />
<ClCompile Include="def\imgui\imgui.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="def\imgui\imgui_demo.cpp" />
<ClCompile Include="def\imgui\imgui_draw.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="def\imgui\imgui_tables.cpp" />
<ClCompile Include="def\imgui\imgui_widgets.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="def\imgui\impl\imgui_impl_dx9.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="def\imgui\impl\imgui_impl_win32.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="def\utils\util.cpp" />
<ClCompile Include="entry.cpp" />
<ClCompile Include="menu\config\config.cpp" />
<ClCompile Include="entry.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="menu\ui.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="clicker\clicker.hpp" />
<ClInclude Include="def\include\console\console.hpp" />
<ClInclude Include="def\include\imgui\fonts\fontawesome.hpp" />
<ClInclude Include="def\include\imgui\fonts\font_definitions.hpp" />
<ClInclude Include="def\include\imgui\imconfig.h" />
<ClInclude Include="def\include\imgui\imgui.h" />
<ClInclude Include="def\include\imgui\imgui_internal.h" />
<ClInclude Include="def\include\imgui\impl\imgui_impl_dx9.h" />
<ClInclude Include="def\include\imgui\impl\imgui_impl_win32.h" />
<ClInclude Include="def\include\imgui\imstb_rectpack.h" />
<ClInclude Include="def\include\imgui\imstb_textedit.h" />
<ClInclude Include="def\include\imgui\imstb_truetype.h" />
<ClInclude Include="def\include\lazy.hpp" />
<ClInclude Include="def\include\singleton.hpp" />
<ClInclude Include="def\include\xorstr.hpp" />
<ClInclude Include="def\config\archivex.hpp" />
<ClInclude Include="def\config\config.hpp" />
<ClInclude Include="def\console.hpp" />
<ClInclude Include="def\imgui\fonts\fontawesome.hpp" />
<ClInclude Include="def\imgui\fonts\font_definitions.hpp" />
<ClInclude Include="def\imgui\imconfig.h" />
<ClInclude Include="def\imgui\imgui.h" />
<ClInclude Include="def\imgui\imgui_internal.h" />
<ClInclude Include="def\imgui\impl\imgui_impl_dx9.h" />
<ClInclude Include="def\imgui\impl\imgui_impl_win32.h" />
<ClInclude Include="def\imgui\imstb_rectpack.h" />
<ClInclude Include="def\imgui\imstb_textedit.h" />
<ClInclude Include="def\imgui\imstb_truetype.h" />
<ClInclude Include="def\includes.hpp" />
<ClInclude Include="def\utils\util.hpp" />
<ClInclude Include="def\utils\vars.hpp" />
<ClInclude Include="includes.hpp" />
<ClInclude Include="menu\config\archivex.hpp" />
<ClInclude Include="menu\config\config.hpp" />
<ClInclude Include="menu\ui.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{25C13AC6-6ACC-42C9-8422-559D75DE0A86}</ProjectGuid>
Expand Down Expand Up @@ -105,6 +119,7 @@
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>stdafx.hpp</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
91 changes: 39 additions & 52 deletions clicker.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,94 +36,81 @@
<ClCompile Include="clicker\clicker.cpp">
<Filter>clicker</Filter>
</ClCompile>
<ClCompile Include="def\include\console\console.cpp">
<Filter>def\include\console</Filter>
<ClCompile Include="def\utils\util.cpp">
<Filter>def\utils</Filter>
</ClCompile>
<ClCompile Include="menu\ui.cpp">
<Filter>menu</Filter>
</ClCompile>
<ClCompile Include="def\include\imgui\impl\imgui_impl_dx9.cpp">
<ClCompile Include="entry.cpp" />
<ClCompile Include="def\imgui\impl\imgui_impl_dx9.cpp">
<Filter>def\include\imgui\impl</Filter>
</ClCompile>
<ClCompile Include="def\include\imgui\impl\imgui_impl_win32.cpp">
<ClCompile Include="def\imgui\impl\imgui_impl_win32.cpp">
<Filter>def\include\imgui\impl</Filter>
</ClCompile>
<ClCompile Include="def\include\imgui\imgui.cpp">
<ClCompile Include="def\imgui\imgui.cpp">
<Filter>def\include\imgui</Filter>
</ClCompile>
<ClCompile Include="def\include\imgui\imgui_draw.cpp">
<ClCompile Include="def\imgui\imgui_draw.cpp">
<Filter>def\include\imgui</Filter>
</ClCompile>
<ClCompile Include="def\include\imgui\imgui_widgets.cpp">
<ClCompile Include="def\imgui\imgui_widgets.cpp">
<Filter>def\include\imgui</Filter>
</ClCompile>
<ClCompile Include="def\utils\util.cpp">
<Filter>def\utils</Filter>
</ClCompile>
<ClCompile Include="menu\config\config.cpp">
<Filter>menu\config</Filter>
</ClCompile>
<ClCompile Include="menu\ui.cpp">
<Filter>menu</Filter>
</ClCompile>
<ClCompile Include="entry.cpp" />
<ClCompile Include="def\config\config.cpp" />
<ClCompile Include="def\imgui\imgui_demo.cpp" />
<ClCompile Include="def\imgui\imgui_tables.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="clicker\clicker.hpp">
<Filter>clicker</Filter>
</ClInclude>
<ClInclude Include="def\include\console\console.hpp">
<Filter>def\include\console</Filter>
<ClInclude Include="def\utils\util.hpp">
<Filter>def\utils</Filter>
</ClInclude>
<ClInclude Include="def\utils\vars.hpp">
<Filter>def\utils</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\fonts\font_definitions.hpp">
<ClInclude Include="menu\ui.hpp">
<Filter>menu</Filter>
</ClInclude>
<ClInclude Include="def\imgui\fonts\font_definitions.hpp">
<Filter>def\include\imgui\fonts</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\fonts\fontawesome.hpp">
<ClInclude Include="def\imgui\fonts\fontawesome.hpp">
<Filter>def\include\imgui\fonts</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\impl\imgui_impl_dx9.h">
<ClInclude Include="def\imgui\impl\imgui_impl_dx9.h">
<Filter>def\include\imgui\impl</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\impl\imgui_impl_win32.h">
<ClInclude Include="def\imgui\impl\imgui_impl_win32.h">
<Filter>def\include\imgui\impl</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imconfig.h">
<ClInclude Include="def\imgui\imconfig.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imgui.h">
<ClInclude Include="def\imgui\imgui.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imgui_internal.h">
<ClInclude Include="def\imgui\imgui_internal.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imstb_rectpack.h">
<ClInclude Include="def\imgui\imstb_rectpack.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imstb_textedit.h">
<ClInclude Include="def\imgui\imstb_textedit.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\imgui\imstb_truetype.h">
<ClInclude Include="def\imgui\imstb_truetype.h">
<Filter>def\include\imgui</Filter>
</ClInclude>
<ClInclude Include="def\include\xorstr.hpp">
<Filter>def\include</Filter>
</ClInclude>
<ClInclude Include="def\include\lazy.hpp">
<Filter>def\include</Filter>
</ClInclude>
<ClInclude Include="def\utils\util.hpp">
<Filter>def\utils</Filter>
</ClInclude>
<ClInclude Include="def\utils\vars.hpp">
<Filter>def\utils</Filter>
</ClInclude>
<ClInclude Include="menu\config\archivex.hpp">
<Filter>menu\config</Filter>
</ClInclude>
<ClInclude Include="menu\config\config.hpp">
<Filter>menu\config</Filter>
</ClInclude>
<ClInclude Include="menu\ui.hpp">
<Filter>menu</Filter>
</ClInclude>
<ClInclude Include="includes.hpp" />
<ClInclude Include="def\include\singleton.hpp" />
<ClInclude Include="def\console.hpp" />
<ClInclude Include="def\includes.hpp" />
<ClInclude Include="def\config\archivex.hpp" />
<ClInclude Include="def\config\config.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
</ItemGroup>
</Project>
44 changes: 20 additions & 24 deletions clicker/clicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,72 @@ DWORD __stdcall clicker::work( LPVOID lParam )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );

if ( config.clicker.hotkey_enabled
&& util::window::get_active_window_title( ).find( config.clicker.window_title ) != std::string::npos )
if ( config.clicker.hotkey_enabled && util::get_active_window_title( ).find( config.clicker.window_title ) != std::string::npos )
{
if ( config.clicker.left_enabled && var::b_l_mouse_down )
if ( config.clicker.left_enabled && vars::b_l_mouse_down )
{
if ( var::b_l_first_click )
if ( vars::b_l_first_click )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 30 ) );
util::input::left_up( );
var::b_l_first_click = false;
vars::b_l_first_click = false;
}
else
{
auto random_delay = util::math::random_int
auto random_delay = util::random_int
(
1000 / ( config.clicker.l_min_cps + config.clicker.l_max_cps * ( int ) 0.2 ),
1000 / ( config.clicker.l_min_cps + config.clicker.l_max_cps * ( int ) 0.48 )
); // old meth logic, will change to something better later ;c

if ( ( std::clock( ) - var::l_last_click_time ) > random_delay )
if ( ( std::clock( ) - vars::l_last_click_time ) > random_delay )
{
util::input::left_down( );
var::l_last_click_time = std::clock( );
vars::l_last_click_time = std::clock( );

if ( config.clicker.blockhit && config.clicker.blockhit_chance > 0 && std::rand( ) % ( 100 / config.clicker.blockhit_chance ) == 0 )
util::input::right_down( );

std::this_thread::sleep_for( std::chrono::milliseconds( util::math::random_int( 30, 50 ) ) );
std::this_thread::sleep_for( std::chrono::milliseconds( util::random_int( 30, 50 ) ) );
util::input::left_up( );

if ( config.clicker.blockhit )
util::input::right_up( );

var::i_clicks_this_session++;

_log( LDEBUG, "l_click random_delay %d clock %d last click time %d", random_delay, std::clock( ), var::l_last_click_time );
vars::i_clicks_this_session++;

_log( LDEBUG, "l_click random_delay %d clock %d last click time %d", random_delay, std::clock( ), vars::l_last_click_time );
}
}
}

// ultra weird way to make this
if ( config.clicker.right_enabled && var::b_r_mouse_down )
if ( config.clicker.right_enabled && vars::b_r_mouse_down )
{
if ( var::b_r_first_click )
if ( vars::b_r_first_click )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 30 ) );
util::input::right_up( );
var::b_r_first_click = false;
vars::b_r_first_click = false;
}
else
{
auto random_delay = util::math::random_int
auto random_delay = util::random_int
(
1000 / ( config.clicker.r_min_cps + config.clicker.r_max_cps * ( int ) 0.2 ),
1000 / ( config.clicker.r_min_cps + config.clicker.r_max_cps * ( int ) 0.48 )
); // old meth logic, will change to something better later ;c
);

if ( ( std::clock( ) - var::l_last_click_time ) > random_delay )
if ( ( std::clock( ) - vars::l_last_click_time ) > random_delay )
{
util::input::right_down( );
var::l_last_click_time = std::clock( );
vars::l_last_click_time = std::clock( );

std::this_thread::sleep_for( std::chrono::milliseconds( util::math::random_int( 30, 50 ) ) );
std::this_thread::sleep_for( std::chrono::milliseconds( util::random_int( 30, 50 ) ) );
util::input::right_up( );

var::i_clicks_this_session++;

_log( LDEBUG, "r_click random_delay %d clock %d last click time %d", random_delay, std::clock( ), var::l_last_click_time );
vars::i_clicks_this_session++;

_log( LDEBUG, "r_click random_delay %d clock %d last click time %d", random_delay, std::clock( ), vars::l_last_click_time );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clicker/clicker.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "../includes.hpp"
#include "../def/includes.hpp"

namespace clicker
{
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions menu/config/config.cpp → def/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ c_config config;

void c_config::run( const char *name )
{
PWSTR path_to_documents;
if ( SUCCEEDED( LI_FN( SHGetKnownFolderPath ).cached( )( FOLDERID_Documents, 0, nullptr, &path_to_documents ) ) )
PWSTR path_to_appdata;
if ( SUCCEEDED( SHGetKnownFolderPath( FOLDERID_RoamingAppData, 0, nullptr, &path_to_appdata ) ) )
{
path = path_to_documents;
path = path_to_appdata;
path /= name;

LI_FN( CoTaskMemFree ).cached( )( path_to_documents );
CoTaskMemFree( path_to_appdata );
}

if ( !std::filesystem::is_directory( path ) )
Expand Down
3 changes: 2 additions & 1 deletion menu/config/config.hpp → def/config/config.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "../includes.hpp"
#include "archivex.hpp"
#include "../../def/includes.hpp"

#include <ShlObj.h>
#include <fstream>
Expand All @@ -23,6 +23,7 @@ class c_config final
{
bool left_enabled { false };
bool right_enabled { false };

bool hotkey_enabled { false };
bool config_show { false };
bool blockhit { false };
Expand Down
Loading

0 comments on commit 99eac48

Please sign in to comment.