- Joined
- Dec 1, 2007
- Messages
- 2,795
- Reaction score
- 480
Trying to simulate a left click after in the current cursor location but so far no luck, I'm hoping you can help me out abit here.
Basically what I'm trying to do is, when the scroll-wheel is clicked it will automatically switch to weapon 6 [F6], then 'fire' the weapon once [left-click], and then switch to weapon 3 [F3].
Basically everything is finished except simulating the mouse click and make the form run as a background process.
Basically what I'm trying to do is, when the scroll-wheel is clicked it will automatically switch to weapon 6 [F6], then 'fire' the weapon once [left-click], and then switch to weapon 3 [F3].
Basically everything is finished except simulating the mouse click and make the form run as a background process.
PHP:
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;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
private static extern void mouse_event(
UInt32 dwFlags, // motion and click options
UInt32 dx, // horizontal position or change
UInt32 dy, // vertical position or change
UInt32 dwData, // wheel movement
IntPtr dwExtraInfo // application-defined information
);
public static void PerformSingleLeftMouseClick(Point cursorLocation)
{
const UInt32 MOUSEEVENTF_LEFTDOWN = 0x02; /* right button down */
const UInt32 MOUSEEVENTF_LEFTUP = 0x04; /* right button up */
UInt32 x = Convert.ToUInt32(cursorLocation.X);
UInt32 y = Convert.ToUInt32(cursorLocation.Y);
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, new IntPtr());
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, new IntPtr());
}
public Form1()
{
InitializeComponent();
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
// future stuff MessageBox.Show(this, "Left Button Click");
break;
case MouseButtons.Right:
// future stuff MessageBox.Show(this, "Right Button Click");
break;
case MouseButtons.Middle:
// future stuff MessageBox.Show("Middle Button Click");
SendKeys.Send("{F6}");
// need to make a left click here
SendKeys.Send("{F3}");
break;
default:
break;
}
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}