using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
////移动到左上角
Cursor.Position = new Point(Screen.PrimaryScreen.WorkingArea.Left, Screen.PrimaryScreen.WorkingArea.Top);
//System.Threading.Thread.Sleep(1000);
////移动到右上角
//Cursor.Position = new Point(Screen.PrimaryScreen.WorkingArea.Right, Screen.PrimaryScreen.WorkingArea.Top);
int dx = 10 * 65535 / Screen.PrimaryScreen.Bounds.Width;
int dy = 10 * 65535 / Screen.PrimaryScreen.Bounds.Height; //mouse_event((int)MouseEventFlags.LeftDown, 0, 0, 0, UIntPtr.Zero); ///MessageBox.Show(Screen.PrimaryScreen.Bounds.Width.ToString());
//改变鼠标位置OK
Cursor.Position = new Point(1000,100);
System.Threading.Thread.Sleep(1000);
//
//右键OK
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
System.Threading.Thread.Sleep(1000);
Cursor.Position = new Point(800,200);
//改变鼠标位置OK
//右键 这里不OK ??是怎么回事
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
} [Flags]
public enum MouseEventFlags
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
Wheel = 0x0800,
Absolute = 0x8000
} [DllImport("user32.dll")]
public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo); }
}
解决方案 »
- 一个winform程序,用到了access数据库,用VS自带的打包部署时,怎么让用户不安装office2007就能正常使用程序啊
- winform如何加载Access数据库文件并显示在datagridview
- VS2008 C#如何读取ACCESS2010数据库
- 打开word后怎样只能使用word本身退出
- 窗体是不是控件。。
- C#链接打开winform窗体
- 加密解密时遇到难题,速度太慢~~
- 明天上午毕业答辩,有段代码看不明白,还请各位高手帮帮忙给我注释一下!(十万火急!!!)
- 高分悬赏高难度问题,C#+Lucene.net方面的大侠请到这里坐客一下!(分不够可追加)
- c# 验证码识别
- 进度条问题
- DataGridView 单元格显示百分比进度条
//右键 这里不OK ??是怎么回事
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
//为什么第一次是OK的而第二次却不行呢
谢谢
Cursor.Position = new Point(Screen.PrimaryScreen.WorkingArea.Left, Screen.PrimaryScreen.WorkingArea.Top);
//System.Threading.Thread.Sleep(1000);
////移动到右上角
//Cursor.Position = new Point(Screen.PrimaryScreen.WorkingArea.Right, Screen.PrimaryScreen.WorkingArea.Top);
int dx = 10 * 65535 / Screen.PrimaryScreen.Bounds.Width;
int dy = 10 * 65535 / Screen.PrimaryScreen.Bounds.Height; //mouse_event((int)MouseEventFlags.LeftDown, 0, 0, 0, UIntPtr.Zero); ///MessageBox.Show(Screen.PrimaryScreen.Bounds.Width.ToString());
//改变鼠标位置OK
Cursor.Position = new Point(1000, 100);
System.Threading.Thread.Sleep(1000);
//
//右键OK
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
mouse_event((int)MouseEventFlags.RightUp, 0, 0, 0, IntPtr.Zero);
System.Threading.Thread.Sleep(1000);
Cursor.Position = new Point(800, 200);
//改变鼠标位置OK
//右键 这里不OK ??是怎么回事
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
mouse_event((int)MouseEventFlags.RightUp, 0, 0, 0, IntPtr.Zero);
Windows.Forms.Cursor.Position = new Point(1000, 100);
System.Threading.Thread.Sleep(10);
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
System.Threading.Thread.Sleep(10);
mouse_event((int)MouseEventFlags.RightUp, 0, 0, 0, IntPtr.Zero);
System.Threading.Thread.Sleep(1000);
Windows.Forms.Cursor.Position = new Point(800, 200);
mouse_event((int)MouseEventFlags.RightDown, 0, 0, 0, IntPtr.Zero);
System.Threading.Thread.Sleep(10);
mouse_event((int)MouseEventFlags.RightUp, 0, 0, 0, IntPtr.Zero);