Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C# auto clicker [help]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
lossev
Master Cheater
Reputation: 0

Joined: 12 Jan 2007
Posts: 296
Location: Sweden

PostPosted: Thu Dec 04, 2008 5:52 am    Post subject: C# auto clicker [help] Reply with quote

Hi, im trying to make an auto clicker in c# but im stuck, i dont know what else to try, (its in windows form application).

Here's what ive manage to do, can anyone help me out?
(im not that good of a coder yet, im still just learning).

To make the code work you have to add the controls used ofc.

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace autoclicker
{
    public partial class Form1 : Form
    {
       
       
        MouseEventArgs auto;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }
        private void mouse(MouseButtons button)
        {
           
           
                OnMouseClick(auto);
                System.Threading.Thread.Sleep(10);
               
           
       
        }
       

        private void button1_Click(object sender, EventArgs e)
        {
           
            mouse(MouseButtons.Left);
           
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            auto = new MouseEventArgs(MouseButtons.Right, 1, MousePosition.X, MousePosition.Y, 0);
        }
    }
}


thanks for helping me Wink

_________________
Oreo's and milk Wink
Back to top
View user's profile Send private message
Fronzel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Feb 2008
Posts: 1099
Location: Nexons backyard

PostPosted: Thu Dec 04, 2008 7:43 am    Post subject: Reply with quote

I would use sendmessaage, you can send mousebutton down and up with it using:

Code:


WM_LBUTTONDOWN = 0x201, //Left mousebutton down
        WM_LBUTTONUP = 0x202,  //Left mousebutton up





Here's an example to click the button "5" in windows calculator:



Code:
IntPtr hwnd = FindWindow("SciCalc", "Calculator");
IntPtr fiveKey = FindWindowEx(hwnd, IntPtr.Zero, "Button", "5");

SendMessage(fiveKey, (int)WMessages.WM_LBUTTONDOWN, 0, 0);
SendMessage(fiveKey, (int)WMessages.WM_LBUTTONUP, 0, 0);




define findwindow like this:


Code:


[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent,
     IntPtr hwndChildAfter,
     string lpszClass,
     string lpszWindow
);



_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Dec 04, 2008 7:59 am    Post subject: Reply with quote

also can be done by using mouse_event API
look up at msdn for more info
Back to top
View user's profile Send private message
lossev
Master Cheater
Reputation: 0

Joined: 12 Jan 2007
Posts: 296
Location: Sweden

PostPosted: Thu Dec 04, 2008 8:17 am    Post subject: Reply with quote

thanks guys Wink
_________________
Oreo's and milk Wink
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Sun Dec 07, 2008 12:38 pm    Post subject: Reply with quote

did sendmessage actually work?

wait, is this for maplestory? cuz i think the only way for maplestory is to use postmessage

_________________
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites