← Foro de Tecnologías .NET

Uso del APi del mouse Conseguido Elph!!

Hilo en el foro de Tecnologías .NET · 19 de Febrero del 2004 · 2 respuestas
infiltrado19 de Febrero del 2004
Pregunta

pos nada ya termine el programilla del autoclick usando la Api del mouse

y va de vicio

solo decirte que muchas gracias por tu apoyo :)

si estas interesado en que muestre una llamada a la api solo tienes que decirlo

saludos

Respuestas 2

Elph19 de Febrero del 2004
^_^
Claro q me gustaria ver ese codigo... Postealo o enviamelo a mi mail..
Nos vemos..
infiltrado19 de Febrero del 2004
creas una clase con este codigo
using System;
using System.Runtime.InteropServices;

namespace DLLUTILS
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class WINAPI
{
public WINAPI()
{
//
// TODO: Add constructor logic here
//
}

[DllImport("User32.dll")]
public static extern void mouse_event(int dwFlags,int dx,int dy,int dwData);
[DllImport("User32.dll")]
public static extern void keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);


}
}

-----------------------------------------------------
Ahora creas el winform con este otro

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace DLLUTIL
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.ComponentModel.IContainer components;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
MessageBox.Show("Version 0.9 BETA en Desarrollo");
button5.Enabled=false;



//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button3 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.button5 = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(288, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 0;
this.button1.Text = "Start";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(56, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(16, 72);
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(56, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(72, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 20);
this.label1.TabIndex = 5;
this.label1.Text = "Tiempo de Repetición ";
//
// label2
//
this.label2.Location = new System.Drawing.Point(73, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(104, 14);
this.label2.TabIndex = 6;
this.label2.Text = "Tiempo pendiente ";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(368, 112);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DON´T PIKE DON´T IMITATE";
//
// button3
//
this.button3.Location = new System.Drawing.Point(288, 44);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(72, 24);
this.button3.TabIndex = 2;
this.button3.Text = "Grabación";
this.button3.Click += new System.EventHandler(this.button3_Click_1);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.Red;
this.panel1.Controls.Add(this.pictureBox2);
this.panel1.Location = new System.Drawing.Point(200, 16);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(72, 80);
this.panel1.TabIndex = 1;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(8, 8);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(56, 64);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
//
// button5
//
this.button5.Location = new System.Drawing.Point(288, 80);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(72, 24);
this.button5.TabIndex = 1;
this.button5.Text = "Stop";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(16, 64);
this.textBox3.Name = "textBox3";
this.textBox3.ReadOnly = true;
this.textBox3.Size = new System.Drawing.Size(56, 20);
this.textBox3.TabIndex = 4;
this.textBox3.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(72, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 14);
this.label3.TabIndex = 6;
this.label3.Text = "Tiempo pendiente ";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(16, 24);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(56, 20);
this.textBox4.TabIndex = 3;
this.textBox4.Text = "";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem3,
this.menuItem5});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "Archivo";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Salir";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4});
this.menuItem3.Text = "Modalidad";
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "Cronometro";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 2;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6});
this.menuItem5.Text = "Ayuda";
//
// menuItem6
//
this.menuItem6.Index = 0;
this.menuItem6.Text = "Acerca de...";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.LightGray;
this.ClientSize = new System.Drawing.Size(382, 127);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox4);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Auto-Click del mouse v.0.9";
this.TopMost = true;
this.TransparencyKey = System.Drawing.SystemColors.ActiveBorder;
this.groupBox1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{

clickMouse();
button5.Enabled=true;


}

private void clickMouse()
{

int Calcula=0;
int interval=1000;




if ((textBox1.Text!=""))
{
this.panel1.BackColor= System.Drawing.Color.Lime;

Calcula=Int32.Parse(textBox1.Text);

Calcula= Calcula *1000;

timer1.Interval=Calcula;
timer2.Interval=interval;

timer1.Enabled=true;
timer2.Enabled=true;


}
else
{
MessageBox.Show("Introduce un valor entero");

}


}


private void button5_Click(object sender, System.EventArgs e)
{
timer1.Stop();
timer1.Dispose();

this.panel1.BackColor = System.Drawing.Color.Red;

}



private void timer1_Tick(object sender, System.EventArgs e)
{

int intervalo=timer1.Interval;
intervalo=intervalo/1000;


const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;



DLLUTILS.WINAPI.mouse_event(MOUSEEVENTF_LEFTDOWN,1,1,0);
DLLUTILS.WINAPI.mouse_event(MOUSEEVENTF_LEFTUP,1,1,0);
}



private void button3_Click_1(object sender, System.EventArgs e)
{
MessageBox.Show("En Desarrollo...");
}

private void menuItem2_Click(object sender, System.EventArgs e)
{
this.Close();

}

private void menuItem4_Click(object sender, System.EventArgs e)
{


MessageBox.Show("en Desarrollo");

}















}
}



:))) pos ya ta le falta controlar que el usuario no meta letras en el text box solo numeros pero eso ya son municias

¿Buscas más hilos como este? Mira el foro de Tecnologías .NET o usa el buscador.