Skip to content

Commit

Permalink
Back to GetAsyncKeyState, more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
b1scoito committed Feb 10, 2022
1 parent 8b48a06 commit df992b3
Show file tree
Hide file tree
Showing 22 changed files with 3,190 additions and 1,628 deletions.
22 changes: 7 additions & 15 deletions clicker/clicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@ void c_clicker::initialize()
vars::key::clicker_enabled.i_mode = config.clicker.i_key_type;
vars::key::clicker_enabled.i_key = config.clicker.i_clicker_key;

if ( vars::key::clicker_enabled.get() )
{
if ( focus::window_think() && focus::cursor_think() )
{
if ( vars::key::clicker_enabled.get() ) {
if ( focus::window_think() && focus::cursor_think() ) {
// left
this->is_left_clicking = ( config.clicker.b_enable_left_clicker && vars::key::is_left_down.get());
if ( this->is_left_clicking )
this->send_click(input::mouse_button_t::left, config.clicker.f_left_cps, vars::key::is_left_down.b_state);
this->send_click(input::mouse_button_t::left, config.clicker.f_left_cps);

// right
this->is_right_clicking = ( config.clicker.b_enable_right_clicker && vars::key::is_right_down.get());
if ( this->is_right_clicking )
this->send_click(input::mouse_button_t::right, config.clicker.f_right_cps, vars::key::is_left_down.b_state);
this->send_click(input::mouse_button_t::right, config.clicker.f_right_cps);
}
}
}
}

void c_clicker::send_click(input::mouse_button_t b_button, float f_cps, bool& b_is_first_click )
void c_clicker::send_click(input::mouse_button_t b_button, float f_cps )
{
const auto start = std::chrono::high_resolution_clock::now();

Expand All @@ -44,13 +42,6 @@ void c_clicker::send_click(input::mouse_button_t b_button, float f_cps, bool& b_
if ( !config.clicker.b_enable_blatant )
this->delay += rng::random_real<float>( -config.clicker.f_default_timer_randomization,
config.clicker.f_default_timer_randomization );

if ( b_is_first_click )
{
PreciseSleep( this->delay );
input::click( input::mouse_input_type_t::up, b_button );
b_is_first_click = false;
}

PreciseSleep( this->delay );
input::click( input::mouse_input_type_t::down, b_button );
Expand Down Expand Up @@ -79,8 +70,9 @@ void c_clicker::send_click(input::mouse_button_t b_button, float f_cps, bool& b_

++vars::stats::i_clicks_this_session;

log_debug( "[%d]: CPS: [ %.3f ] Delay: [ %.3fms ] Time elapsed: [ %.3fms ] Avg CPS: [ %.3fms ]",
log_debug( "[%d, %s]: CPS: [ %.3f ] Delay: [ %.3fms ] Time elapsed: [ %.3fms ] Avg CPS: [ %.3f ]",
vars::stats::i_clicks_this_session,
config.clicker.i_send_input_method ? "PostMessage" : "SendMessage",
f_cps,
( this->delay * 2 ),
elapsed.count(),
Expand Down
2 changes: 1 addition & 1 deletion clicker/clicker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class c_clicker
{
private:
void send_click( input::mouse_button_t b_button, float f_cps, bool& b_is_first_click );
void send_click( input::mouse_button_t b_button, float f_cps );

float delay = 0.f;
float random = 0.f;
Expand Down
3 changes: 0 additions & 3 deletions clicker/clicker.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@
<Filter Include="utils\vars">
<UniqueIdentifier>{c87a7cbb-b9a7-4307-b963-a65bc9292368}</UniqueIdentifier>
</Filter>
<Filter Include="utils\threads">
<UniqueIdentifier>{2fddc2fe-d959-4e3a-b967-7234b06e9dc9}</UniqueIdentifier>
</Filter>
<Filter Include="utils\imgui\stb">
<UniqueIdentifier>{64418ae5-488a-44f0-aa10-d31c2dc334ad}</UniqueIdentifier>
</Filter>
Expand Down
1 change: 1 addition & 0 deletions clicker/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class c_config
int i_clicker_key { 0 };
int i_key_type { 0 };
int i_version_type { 0 };
int i_send_input_method { 0 };

bool b_enable_left_clicker { false };
bool b_enable_right_clicker { false };
Expand Down
1 change: 1 addition & 0 deletions clicker/imgui/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.

//---- Disable all of Dear ImGui or don't implement standard windows.
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
Expand Down
2,610 changes: 1,739 additions & 871 deletions clicker/imgui/imgui.cpp

Large diffs are not rendered by default.

493 changes: 312 additions & 181 deletions clicker/imgui/imgui.h

Large diffs are not rendered by default.

Loading

0 comments on commit df992b3

Please sign in to comment.