希望对你有帮助:http://wwsys.51.net/start.htm
解决方案 »
- 数据库 表被锁 要做更新操作 一直超时 求解决方案
- 用C#做的网络爬虫如何抓取动态页面
- 在自定义安装类中重载Install(System.Collections.IDictionary stateSaver)加入base.Rollback(stateSaver)怎么会错误啊。。。
- 关于枚举.......
- 关于C#调用DLL的问题
- VS无法加载MSXML3.DLL ??why?
- 关于动态生成的控件位置的问题:为什么指顶了parent,他的位置却不在父容器里呢
- 在datagridview已经绑定的数据里动态添加数据到数据库
- gridview控件的排序扩展
- 最简单的问题,怎样实例化一个类?初学CS,请不要笑话!
- 在制作安装项目时,有谁碰到过这种情况?
- 我是想动态得到一个矩形框
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
private void treeView1_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
//code here
}
using System;
using System.Runtime.InteropServices;
using System.Text;namespace ConsoleApplication8{
class Class1{
[STAThread]
static void Main(string[] args){
// Display current status of keys.
Console.WriteLine(
"**BEFORE**\r\nCAP: {0}\r\nSCR: {1}\r\nNUM: {2}",
Keyboard.GetState(VirtualKeys.VK_CAPITAL)?"ON":"OFF",
Keyboard.GetState(VirtualKeys.VK_SCROLL)?"ON":"OFF",
Keyboard.GetState(VirtualKeys.VK_NUMLOCK)?"ON":"OFF"
);
//Toggle all the keys:
Keyboard.SetState(
VirtualKeys.VK_CAPITAL,
!Keyboard.GetState(VirtualKeys.VK_CAPITAL)
);
Keyboard.SetState(
VirtualKeys.VK_SCROLL,
!Keyboard.GetState(VirtualKeys.VK_SCROLL)
);
Keyboard.SetState(
VirtualKeys.VK_NUMLOCK,
!Keyboard.GetState(VirtualKeys.VK_NUMLOCK)
);
// Display new status of keys.
Console.WriteLine(
"\r\n**AFTER**\r\nCAP: {0}\r\nSCR: {1}\r\nNUM: {2}",
Keyboard.GetState(VirtualKeys.VK_CAPITAL)?"ON":"OFF",
Keyboard.GetState(VirtualKeys.VK_SCROLL)?"ON":"OFF",
Keyboard.GetState(VirtualKeys.VK_NUMLOCK)?"ON":"OFF"
);
Console.ReadLine();
}
}
public enum VirtualKeys: byte{
VK_NUMLOCK = 0x90,
VK_SCROLL = 0x91,
VK_CAPITAL = 0x14
}
class Keyboard{
const uint KEYEVENTF_EXTENDEDKEY = 0x1;
const uint KEYEVENTF_KEYUP = 0x2;
[DllImport("user32.dll")]
static extern short GetKeyState(int nVirtKey);
[DllImport("user32.dll")]
static extern void keybd_event(
byte bVk,
byte bScan,
uint dwFlags,
uint dwExtraInfo
);
public static bool GetState(VirtualKeys Key){
return (GetKeyState((int)Key)==1);
}
public static void SetState(VirtualKeys Key, bool State){
if(State!=GetState(Key)){
keybd_event(
(byte)Key,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0
);
keybd_event(
(byte)Key,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0
);
}
}
}
}
//and you can do mouse_event operation like it.
Top
回复人:seabirdforever(听海) ( ) 信誉:100 2003-3-24 10:46:56 得分:0
?
建议你参考 一下 《Microsoft C#程序设计》(北大出版社,上下册带光盘160元),里面关于 鼠标和键盘的东西有详细的论述
Top
回复人:TheAres(班门斧) ( ) 信誉:162 2003-3-25 0:24:03 得分:50
? 对于模拟键盘,除了利用keybd_event,更简单的是使用sendkeys,而且keybd_event已经被sendinput取代。具体代码参考:
请问,用C#如何实现模拟键盘输入
http://expert.csdn.net/Expert/topic/1055/1055110.xml?temp=.1404993对于模拟鼠标,只好用SendInput,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputFunctions/SendInput.asp具体代码参考:
http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&threadm=665201c200e8%24e3a1f550%2435ef2ecf%40TKMSFTNGXA11&rnum=3&prev=/groups%3Fq%3Dsendinput%2Bmouse%2Bc%2523%26hl%3Dzh-CN%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D665201c200e8%2524e3a1f550%252435ef2ecf%2540TKMSFTNGXA11%26rnum%3D3