博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助 

flameschen

空心竹,有魂居,魂生根,在竹心。魂之根,竹之心,不可分。【あ拉钩上吊永不变~我一直爱着你サ】
flameschen.cublog.cn
关于作者  
姓名:陈曦华
职业:学生
年龄:22
位置:湖北武汉
个性介绍:我的网络我的自由

我的分类  




键盘锁定
假期在家表弟表妹们看到电脑就乱敲键盘和鼠标,没事就按到POWER键,让我很是头痛,回到学校没事做就写了个锁定键盘鼠标的程序,这下嘿嘿:)

      鼠标好办,左右互换:

  [DllImport("user32.dll")]
  private extern static bool SwapMouseButton(bool fSwap);

       隐藏光标

  [DllImport("user32.dll")]  
  static extern bool ShowCursor(bool bShow);

锁定鼠标在某区域

  [DllImport("user32.dll")]
  static extern bool ClipCursor(ref RECT lpRect);

键盘事件就要用全局HOOK了,可是把SetWindowsHook最后一个参数为0后根本没反应-_-,一查才知道

You cannot implement global hooks in Microsoft .NET Framework. To install a global hook, a hook must have a native dynamic-link library (DLL) export to inject itself in another process that requires a valid, consistent function to call into. This requires a DLL export, which .NET Framework does not support. Managed code has no concept of a consistent value for a function pointer because these function pointers are proxies that are built dynamically

这时候就我就选择去CodeProject,终于找到一个篇“Processing Global Mouse and Keyboard Hooks in C#”,把类拿来用用吧  我懒喜欢用别人的成果-_-

完成收工  界面麻就不贴了 反正自己用

 发表于: 2008-01-21,修改于: 2008-01-21 20:37
 已浏览419次,有评论0条
推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:0.01255

京ICP证041476号