#How would i make this enable when you hold your mouse down and disable when you stop holding it down

8 messages · Page 1 of 1 (latest)

trail shoal
#
#include <string>
#include <conio.h>
#include <Windows.h>
#include <chrono>
#include <thread>
#include <random>
using namespace std;

int main() {
    int x = 1000;
    int y = 1;
    bool isLeftClicking = false; // Toggle variable to control clicking
    bool isRightClicking = false;

    // Random Number Generation Setup
    random_device rd; // Seed for random number generator
    mt19937 gen(rd()); // Mersenne Twister random number generator
    uniform_int_distribution<> disLeft(20, 40); // Uniform distribution for delays (30ms To 100ms)
    uniform_int_distribution<> disRight(20, 50);

    while (true) { // Infinite loop to keep the program running
        if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) { // Check if left button is pressed
            isLeftClicking = !isLeftClicking; // Toggle Left Clicking state
            cout << (isLeftClicking ? "Left Clicking Enabled" : "Left Clicking Disabled") << endl;
            Sleep(200); // Sleep to prevent multiple inputs from one key press
        }

        if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) { // Check if right button is pressed
            isRightClicking = !isRightClicking; // Toggle Right Clicking state
            cout << (isRightClicking ? "Right Clicking Enabled" : "Right Clicking Disabled") << endl;
            Sleep(200); // Sleep to prevent multiple inputs from one key press
        }

        // Perform Clicking if the toggles are enabled 
        if (isLeftClicking) {
            mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
            Sleep(30);
            mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

            // Random delay between clicks to fluctuate CPS
            int delay = disLeft(gen); // Generate a random delay
            Sleep(delay);
        }

        if (isRightClicking) {
            mouse_event(MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0);
            Sleep(30);
            mouse_event(MOUSEEVENTF_RIGHTUP, x, y, 0, 0);

            // Random delay between clicks to fluctuate CPS
            int delayRight = disRight(gen); // Generate a random delay for right clicks
            Sleep(delayRight);
        }

        // Small sleep to prevent high CPU usage
        Sleep(10);
    }

    return 0;
}```
lone doveBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

halcyon kiln
#

hi @trail shoal

#

nice to meet you.

#

plz use this code
#include <iostream>
#include <string>
#include <conio.h>
#include <Windows.h>
#include <chrono>
#include <thread>
#include <random>

using namespace std;

int main() {
int x = 1000;
int y = 1;

// Random Number Generation Setup
random_device rd; // Seed for random number generator
mt19937 gen(rd()); // Mersenne Twister random number generator
uniform_int_distribution<> disLeft(20, 40); // Uniform distribution for delays (30ms To 100ms)
uniform_int_distribution<> disRight(20, 50);

while (true) { // Infinite loop to keep the program running
    if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) { // Check if left button is pressed
        // Perform left clicking while the button is held down
        mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
        Sleep(30);
        mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

        // Random delay between clicks to fluctuate CPS
        int delay = disLeft(gen); // Generate a random delay
        Sleep(delay);
    }

    if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) { // Check if right button is pressed
        // Perform right clicking while the button is held down
        mouse_event(MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0);
        Sleep(30);
        mouse_event(MOUSEEVENTF_RIGHTUP, x, y, 0, 0);

        // Random delay between clicks to fluctuate CPS
        int delayRight = disRight(gen); // Generate a random delay for right clicks
        Sleep(delayRight);
    }

    // Small sleep to prevent high CPU usage
    Sleep(10);
}

return 0;

}

halcyon kiln
#

i sent you dm

lone doveBOT
#
Why Is `using namespace std` Considered Bad Practice?

using namespace std will import all the symbols from std into the enclosing namespace. This can easily lead to name collisions, as the standard library is filled with common names: get, count, map, array, etc.

A key concern with using namespace std; is not what is imported now but rather what may suddenly be imported in the future.

While using namespace std; is alright for tiny projects, it is important to move away from it as soon as possible. Consider less intrusive alternatives:

// OK: *only* import std::vector
using std::vector;
// OK: namespace alias
namespace chr = std::chrono;
chr::duration x;