
-----------------------------------
Cancer Sol
Tue Apr 02, 2013 10:55 am

Start/Stop function using getch
-----------------------------------
I'm not sure if I shouldn't use conio.h, but I did so I could use the getch function.
Basically, this is a part of my auto-clicker, and if the user pressed three, it'll start the clicking, and if they press three again, it'll stop clicking.


case 51://If the user pressed 3
            {
                while (1)
                {
                    char stop = getch();//I tried to make auto-clicker stop if 3 was pressed, but it won't really work all the time
                    while (stop != 51)//If it's not three, then it'll continue clicking
                    {
                        for (int i=amount; i>0; i--)//I'm going to change this, instead of having the auto-clicker clicking from the last coordinates to the first, it'll be first to last
                        {

                            SetCursorPos(x
Does anyone know how to make it stop if I press three, and make it pause even if the console window isn't highlighted?

-----------------------------------
nullptr
Tue Apr 02, 2013 3:48 pm

Re: Start/Stop function using getch
-----------------------------------
I'm not sure if I shouldn't use conio.h, but I did so I could use the getch function.
Basically, this is a part of my auto-clicker, and if the user pressed three, it'll start the clicking, and if they press three again, it'll stop clicking.


case 51://If the user pressed 3
            {
                while (1)
                {
                    char stop = getch();//I tried to make auto-clicker stop if 3 was pressed, but it won't really work all the time
                    while (stop != 51)//If it's not three, then it'll continue clicking
                    {
                        for (int i=amount; i>0; i--)//I'm going to change this, instead of having the auto-clicker clicking from the last coordinates to the first, it'll be first to last
                        {

                            SetCursorPos(x
Does anyone know how to make it stop if I press three, and make it pause even if the console window isn't highlighted?

As far as I know, the only way to get what you want is to use threads. See http://en.cppreference.com/w/cpp/thread/thread -- you'll need an up-to-date compiler like gcc 4.7. Otherwise, you'd need to wait for user input between each mouse click.

-----------------------------------
Cancer Sol
Tue Apr 02, 2013 5:11 pm

Re: Start/Stop function using getch
-----------------------------------
I'm not sure if I shouldn't use conio.h, but I did so I could use the getch function.
Basically, this is a part of my auto-clicker, and if the user pressed three, it'll start the clicking, and if they press three again, it'll stop clicking.


case 51://If the user pressed 3
            {
                while (1)
                {
                    char stop = getch();//I tried to make auto-clicker stop if 3 was pressed, but it won't really work all the time
                    while (stop != 51)//If it's not three, then it'll continue clicking
                    {
                        for (int i=amount; i>0; i--)//I'm going to change this, instead of having the auto-clicker clicking from the last coordinates to the first, it'll be first to last
                        {

                            SetCursorPos(x
Does anyone know how to make it stop if I press three, and make it pause even if the console window isn't highlighted?

As far as I know, the only way to get what you want is to use threads. See http://en.cppreference.com/w/cpp/thread/thread -- you'll need an up-to-date compiler like gcc 4.7. Otherwise, you'd need to wait for user input between each mouse click.
Will the GNU-GCC compiler that's included with Code Blocks MingW recognize it?

-----------------------------------
Insectoid
Tue Apr 02, 2013 7:16 pm

RE:Start/Stop function using getch
-----------------------------------
It's a library. You install it and include it and it will work. On Windows. Some libraries only work on a specific operating system or architecture. conio.h is one of them.

-----------------------------------
nullptr
Tue Apr 02, 2013 9:50 pm

Re: Start/Stop function using getch
-----------------------------------

. . .


As far as I know, the only way to get what you want is to use threads. See http://en.cppreference.com/w/cpp/thread/thread -- you'll need an up-to-date compiler like gcc 4.7. Otherwise, you'd need to wait for user input between each mouse click.
Will the GNU-GCC compiler that's included with Code Blocks MingW recognize it?

I'm not sure what version is included. Try this code and see if it works:


#include 
#include 

using namespace std;

void test()
{
    cout 