展开全部
using System.Runtime.InteropServices;
public enum MouseEventFlags
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
Wheel = 0x0800,
Absolute = 0x8000
}
[DllImport("user32.dll")]
private static extern int SetCursorPos(int x, int y);
[DllImport("User32")]
public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);
调用:
SetCursorPos(464, 62);//已屏幕为坐标点
SetCursorPos(this.Location.X + 464, this.Location.Y + 62);//已this窗体为坐标点
mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
//100%可用,不懂的继续问我.
追问
键盘的能告诉我么
追答
注册全局热键及代码控件键盘输入按键
using System.Runtime.InteropServices;
namespace ControlKeyboard
{
public partial class ControlKey : Form
{
private void btnStart_Click(object sender, EventArgs e)
{
RegisterHotKey(this.Handle, 469487202, 0, (UInt32)Keys.F2);//注册热键F2
}
private void btnStop_Click(object sender, EventArgs e)
{
UnregisterHotKey(this.Handle, 469487202);//移除热键F2
}
//重写消息循环
protected override void WndProc(ref Message m)
{
if (m.WParam.ToInt32() == 469487202)//F2
{
Thread.Sleep(300);
SendKeys.SendWait("{2}");
Thread.Sleep(300);
SendKeys.SendWait("{2}");
}
base.WndProc(ref m);
}
[DllImport("user32.dll")]
public static extern UInt32 RegisterHotKey(IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk); //API
}
}
2014-10-31
展开全部
模拟鼠标点击和鼠标移动代码我有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
函数原型:
VOID keybd_event( BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo );
4个参数都是输入参数。
bVk:键名,例如: VK_NUMPAD7,VK_BACK, VK_TAB,VK_SHIFT,VK_F1,。。。
keybd_event(VK_MENU,0xb8,0 , 0); -- 按下Alt 键
keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); -- 放开 Alt 键 (复位,弹上来)
===
下面程序模拟按 notepad 编辑器。等于C语言 system("notepad"); 弹出 记事本。
void simu_notepad()
{
keybd_event(VkKeyScan('N'),1,0,0);
keybd_event(VkKeyScan('N'),1,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('O'),0x98,0,0); keybd_event(VkKeyScan('O'),0x98,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('T'),0x94,0,0); keybd_event(VkKeyScan('T'),0x94,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('E'),0x92,0,0); keybd_event(VkKeyScan('E'),0x92,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('P'),0x99,0,0); keybd_event(VkKeyScan('P'),0x99,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('A'),0x9E,0,0); keybd_event(VkKeyScan('A'),0x9E,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('D'),0xA0,0,0); keybd_event(VkKeyScan('D'),0xA0,KEYEVENTF_KEYUP,0);
keybd_event(VK_RETURN,1,0,0);
keybd_event(VK_RETURN,1,KEYEVENTF_KEYUP,0);
}
VOID keybd_event( BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo );
4个参数都是输入参数。
bVk:键名,例如: VK_NUMPAD7,VK_BACK, VK_TAB,VK_SHIFT,VK_F1,。。。
keybd_event(VK_MENU,0xb8,0 , 0); -- 按下Alt 键
keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); -- 放开 Alt 键 (复位,弹上来)
===
下面程序模拟按 notepad 编辑器。等于C语言 system("notepad"); 弹出 记事本。
void simu_notepad()
{
keybd_event(VkKeyScan('N'),1,0,0);
keybd_event(VkKeyScan('N'),1,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('O'),0x98,0,0); keybd_event(VkKeyScan('O'),0x98,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('T'),0x94,0,0); keybd_event(VkKeyScan('T'),0x94,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('E'),0x92,0,0); keybd_event(VkKeyScan('E'),0x92,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('P'),0x99,0,0); keybd_event(VkKeyScan('P'),0x99,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('A'),0x9E,0,0); keybd_event(VkKeyScan('A'),0x9E,KEYEVENTF_KEYUP,0);
keybd_event(VkKeyScan('D'),0xA0,0,0); keybd_event(VkKeyScan('D'),0xA0,KEYEVENTF_KEYUP,0);
keybd_event(VK_RETURN,1,0,0);
keybd_event(VK_RETURN,1,KEYEVENTF_KEYUP,0);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
求字体样式文件!!
sunlyk@qq.com
sunlyk@qq.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询