C++ Learning Community Forum
August 01, 2010, 03:17:52 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: adding more clicks to my auto clicker  (Read 441 times)
oulyt
C++ Freak
***
Posts: 340



View Profile
« on: January 26, 2010, 11:05:59 PM »

Code
GeSHi (cpp):
// Auto clicker written by Oulyt
 
 
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
 
 
using namespace std;
 
int main()
{
 
SetConsoleTitle("Oulyt's AutoClicker");
 
{
cout << "Oulyt's autoclicker" << endl;
       cout << " " << endl;
       cout << " " << endl;
       cout << " " << endl;
 
 
int slpTime,i;
 
cout << "Enter the number of times to click: " << endl;
cin >> i;
 
cout << "Enter time in seconds between clicks: " << endl;
cin >> slpTime;
 
cout <<"Place the mouse where you want it to click and press enter" << endl;
 
       getch();
 
POINT p;
       GetCursorPos(&p);
 
cout << "Status." << "\n X coordinate: " << p.x << " \nY coordinate: ";
cout << p.y << " \nTime in seconds between clicks: " << slpTime << endl;
 
 
       for(int t = 1; t <= i; t++){
SetCursorPos(p.x,p.y);
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, p.x, p.y, 0, 0);
       //mouse_event(MOUSEEVENTF_RIGHTUP, p.x, p.y, 0, 0);
Sleep(slpTime*1000);
 
if (GetAsyncKeyState(VK_ESCAPE)){
exit(0);
}
else continue;
 
}
return 0;
}
}
 
Created by GeSHI 1.0.7.18

so i wrote this bit of code a while ago for an autoclicker to click in the same spot. i tried to add in code so that it could click on however many spots the user wants and the user can pick each spot and it would just go in that order.  What would be the best way to do this?
Logged
ih8censorship
Megalomaniac!!!
Administrator
C++ guru
*****
Posts: 1236



View Profile
« Reply #1 on: January 28, 2010, 02:28:01 AM »

I did something like this once, only mine used enumchildwindows to get the handle of the window i wanted to send click messages to and then sendmessage.

Basically what I was doing, was seeing what the maximum a certain flash animation could handle. It was a paintball thing to see how many balls per second you could shoot if your mouse button was the trigger. It must have had an upper limit, because my program only made it shoot "20 balls per second" and I was doing 12 with my computers touch pad. (in real life, I can pull about 5-7 balls per second. If i had a faster gun i could probably shoot 12 at least.)
Logged

PC==perfect_companion

Knowledge cannot come packaged and predigested; it must be chewed over carefully before swallowed.

What have you tried?
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« Reply #2 on: March 02, 2010, 10:19:08 AM »

I've done this exact thing just in different parts. First got the topmost window under the mouse (in my asm kill program which i believe is on this forum if it isn't just msg me and I'll re-post it) using the api WindowFromPoint this doesn't have to be under the mouse, just i used the moue to get the point.

After that it's just a matter of sending the right message to that window most programs react to WM_LBUTTONDOWN, WM_LBUTTONUP. WM_LBUTTONDBLCLK, BN_CLICKED, BN_DBLCLK, or BN_DOUBLECLICKED. depending on how the program is handling it i'd send WM_LBUTTONDOWN then BN_CLICKED then WM_LBUTTONUP. if you need to have your mouse in a certan position then you can use SetCursorPos, note i've read just having the cursor over a point when the message is sent will fake tell the program the message was sent from the cursor's position, however i have been too lazy to confirm this.

I've also read you can use the SendImput function for this however I have not used this method. But it looks like it's a lower level approach, with a few restrictions.
Logged


Imagine the impossible, then make it happen.
oulyt
C++ Freak
***
Posts: 340



View Profile
« Reply #3 on: March 02, 2010, 10:36:35 PM »

thanks for the post FrozenKnight i'll go try out what you said
Logged
oulyt
C++ Freak
***
Posts: 340



View Profile
« Reply #4 on: April 16, 2010, 09:29:05 PM »

I've done this exact thing just in different parts. First got the topmost window under the mouse (in my asm kill program which i believe is on this forum if it isn't just msg me and I'll re-post it) using the api WindowFromPoint this doesn't have to be under the mouse, just i used the moue to get the point.

After that it's just a matter of sending the right message to that window most programs react to WM_LBUTTONDOWN, WM_LBUTTONUP. WM_LBUTTONDBLCLK, BN_CLICKED, BN_DBLCLK, or BN_DOUBLECLICKED. depending on how the program is handling it i'd send WM_LBUTTONDOWN then BN_CLICKED then WM_LBUTTONUP. if you need to have your mouse in a certan position then you can use SetCursorPos, note i've read just having the cursor over a point when the message is sent will fake tell the program the message was sent from the cursor's position, however i have been too lazy to confirm this.

I've also read you can use the SendImput function for this however I have not used this method. But it looks like it's a lower level approach, with a few restrictions.


well i finally have the time to work on this, and I'm reading through and it seems easy enough but i always find a way to over complicate things. my biggest issue with this program is letting the user decide how many different spots they want to click in and having it loop through that.


hmm... i seem to be having some trouble starting, anybody know a tutorial that would help with the clicks? i can't seem to find any
« Last Edit: April 17, 2010, 08:10:07 PM by oulyt » Logged
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« Reply #5 on: April 26, 2010, 12:04:34 AM »

When i did mine, way back, it was just me and msdn for everything.
if you need help with getting the window to send the click to then browse over to my "Kill" program over in the asm section it uses this method to get the window and to later "Terminate" the process.
as for sending the clicks, well you need to think back as to how you would handle clicks. remember that some windows have their clicks handled by the parent window, which is exceptionally common for dialogs and controls. So you may need to notify the parent window (GetParent) with a BN_CLICKED, to fully simulate the click. As i said you need to think, back to all the methods you have ever used to handle a mouse click and fake each and every one of them. (note: this is often how a hacker thinks, so pull out your zen-hacker attitude for this. It's not hard just takes patients and some thought.)
Logged


Imagine the impossible, then make it happen.
oulyt
C++ Freak
***
Posts: 340



View Profile
« Reply #6 on: April 26, 2010, 02:17:24 AM »

thanks for the tips FrozenKnight Cheesy very much appreciated

i think i'm going to work on this some late night. easier to think.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!