Can someone give me Speed Counter with [Slot2 ] and [botton E]
#pragma once
#include <string>
extern const char* arr[ ];
class VirtualKeyParser
{
public:
static std::string parse_virtual_key( int key_code );
};
#include "key_codes.hpp"
const char* arr[ ] = {
0,
"Left mouse button",
"Right mouse button",
"Control-break",
"Middle mouse button",
"X1 mouse button (ext.)",
"X2 mouse button (ext.)",
0,
"Backspace",
"Tab",
0,
0,
"Clear",
"Enter/Return",
0,
0,
"Shift",
"Control",
"Alt",
"Pause",
"Caps lock",
0,
0,
0,
0,
0,
0,
0,
0,
0,
"Escape",
0,
0,
0,
0,
"Spacebar",
"Page up",
"Page down",
"End",
"Home",
"Left arrow",
"Up arrow",
"Right arrow",
"Down arrow",
"Select",
"Print",
"Execute",
"Print screen",
"Insert",
"Delete",
"Help",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
0,0,0,0,0,0,0,
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"Left Windows key",
"Right Windows key",
"Applications key",
0,
"Sleep key",
"Num0", "Num1", "Num2", "Num3", "Num4", "Num5", "Num6", "Num7", "Num8", "Num9",
"Multiply key",
"Add key",
"Separator key",
"Subtract key",
"Decimal key",
"Divide key",
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13",
"F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24",
0, 0, 0, 0, 0, 0, 0, 0,
"Num lock",
"Scroll lock",
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
"Left shift",
"Right shift",
"Left control",
"Right control",
"Left alt",
"Right alt"
};
std::string VirtualKeyParser::parse_virtual_key( int key_code )
{
return arr[ key_code ];
}
#pragma once
#include <Windows.h>
#include <string>
namespace utils
{
HWND get_proc_hwnd( );
bool keys_released( );
bool get_pressed_key( uint32_t& key );
bool button_clicked( uint32_t key );
void key_down_up( INPUT& input, uint32_t key, uint32_t delay );
}
#include "utils.hpp"
namespace utils
{
HWND tmp = 0;
BOOL CALLBACK enumProc( __in HWND hWnd, __in LPARAM lParam )
{
DWORD proc_id = 0;
if ( GetWindowThreadProcessId( hWnd, &proc_id ) == GetCurrentProcessId( ) )
tmp = hWnd;
return TRUE;
}
HWND get_proc_hwnd( )
{
auto status = EnumWindows( enumProc, 0 );
if ( status )
return tmp;
return 0;
}
bool keys_released( )
{
for ( int i = 0; i <= 0xFE; i++ )
if ( GetAsyncKeyState( i ) )
return false;
return true;
}
bool get_pressed_key( uint32_t& key )
{
for ( int i = 0; i <= 0xFE; i++ )
{
if ( GetAsyncKeyState( i ) )
{
key = i;
return true;
}
}
return false;
}
bool button_clicked( uint32_t key )
{
static bool isDown = false, isClicked = false;
static uint32_t oldKey = key;
if ( oldKey != key )
isDown = false, isClicked = false;
if ( GetAsyncKeyState( key ) )
isDown = true;
else if ( isDown )
{
isDown = false;
isClicked = true;
}
else
{
isDown = false;
isClicked = false;
}
return isClicked;
}
void key_down_up( INPUT& input, uint32_t key, uint32_t delay )
{
input.ki.wVk = key;
input.ki.dwFlags = 0;
SendInput( 1, &input, sizeof( INPUT ) );
Sleep( delay );
input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &input, sizeof( INPUT ) );
Sleep( delay );
}
}
#pragma once #include <Windows.h> #include <cstdint> #include <process.h> #include <TlHelp32.h> #include <string> #include <algorithm> #include <iostream> #include <boost/algorithm/string.hpp> #include <memory>
#include "common_includes.hpp"
#include "key_codes.hpp"
#include "utils.hpp"
std::string gen_random_string( std::size_t length )
{
std::string alpha_lower = "abcdefghijklmnopqrstuvwxyz", ret;
auto alpha_upper = boost::to_upper_copy( alpha_lower );
for ( decltype( length ) i = 0; i < length; i++ )
{
auto what_to_choose_from = ( rand( ) % 2 == 0 ) ? alpha_lower : alpha_upper;
ret += what_to_choose_from[ rand( ) % what_to_choose_from.length( ) ];
}
return ret;
}
struct sc_bot_arglist
{
uint32_t cs_slot, delay, button;
};
void sc_bot( void* arglist )
{
auto args = static_cast< sc_bot_arglist* >( arglist );
uint32_t cs_slot_key = 0;
switch ( args->cs_slot )
{
case 1:
cs_slot_key = 0x31;
break;
case 2:
cs_slot_key = 0x32;
break;
case 3:
cs_slot_key = 0x33;
break;
default:
std::cout << "wat?" << std::endl;
}
INPUT input_keyboard;
input_keyboard.type = INPUT_KEYBOARD;
input_keyboard.ki.wScan = 0;
input_keyboard.ki.time = 0;
input_keyboard.ki.dwExtraInfo = 0;
bool isDown = false, isClicked = false;
while ( true )
{
if ( GetAsyncKeyState( args->button ) )
isDown = true;
else if ( isDown )
{
isDown = false;
isClicked = true;
}
else
{
isDown = false;
isClicked = false;
}
if ( isClicked )
{
utils::key_down_up( input_keyboard, cs_slot_key, args->delay );
utils::key_down_up( input_keyboard, VK_SPACE, args->delay );
input_keyboard.ki.wVk = 'A';
input_keyboard.ki.dwFlags = 0;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
input_keyboard.ki.wVk = VK_SPACE;
input_keyboard.ki.dwFlags = 0;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
Sleep( args->delay );
input_keyboard.ki.wVk = VK_SPACE;
input_keyboard.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
input_keyboard.ki.wVk = 'A';
input_keyboard.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
Sleep( args->delay );
input_keyboard.ki.wVk = VK_RBUTTON;
input_keyboard.ki.dwFlags = 0;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
Sleep( 400 );
input_keyboard.ki.wVk = VK_RBUTTON;
input_keyboard.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &input_keyboard, sizeof( INPUT ) );
}
Sleep( 10 );
}
}
int main( )
{
uint32_t cs_slot, delay, macro_button;
srand( static_cast< unsigned int >( time( nullptr ) ) );
SetConsoleTitleA( gen_random_string( 44 ).c_str( ) );
std::cout << "CS Slot (1-3): ";
std::cin >> cs_slot;
if ( cs_slot < 1 || cs_slot > 3 )
{
std::cout << "Inavlid slot id." << std::endl;
Sleep( 1000 );
TerminateProcess( GetCurrentProcess( ), 0 );
}
std::cout << "Delay (in ms): ";
std::cin >> delay;
std::cout << "Assign button (Press any button): ";
while ( !utils::keys_released( ) )
Sleep( 10 );
while ( !utils::get_pressed_key( macro_button ) )
Sleep( 10 );
std::cout << VirtualKeyParser::parse_virtual_key( macro_button ) << std::endl;
std::cout << "\nMacro successfully setup. Go ingame now. (Press F3 to terminate)\n\n";
ShowWindow( utils::get_proc_hwnd( ), SW_MINIMIZE );
auto args = std::shared_ptr<sc_bot_arglist>( new sc_bot_arglist( ) );
args->cs_slot = cs_slot;
args->delay = delay;
args->button = macro_button;
_beginthread( sc_bot, 0, args.get( ) );
bool isDown = false, isClicked = false;
while ( true )
{
if ( GetAsyncKeyState( VK_F3 ) )
isDown = true;
else if ( isDown )
{
isDown = false;
isClicked = true;
}
else
{
isDown = false;
isClicked = false;
}
if ( isClicked )
{
TerminateProcess( GetCurrentProcess( ), 0 );
}
Sleep( 10 );
}
}