CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

按键模仿鼠标

楼主du51(郁郁思扬)2006-03-18 18:16:06 在 VC/MFC / 基础类 提问

假设一个对话框,上面只有一个按钮.  
  我若不用鼠标点.能不能点Y键.达到和用鼠标点一样的效果.包括按钮被按下去的样子.  
  问题点数:50、回复次数:6Top

1 楼vcmute(BCare4 H1Rest Good9!)回复于 2006-03-18 18:18:16 得分 10

SendInput  
  mouse_eventTop

2 楼du51(郁郁思扬)回复于 2006-03-18 18:19:45 得分 0

首先谢谢楼上的.你能不能讲详细点..  
  我的意思就是说,点鼠标在上面和点Y完全是一样的效果.  
  Top

3 楼du51(郁郁思扬)回复于 2006-03-18 19:11:36 得分 0

帮帮忙呀.顶.Top

4 楼iswjh(哪天我才会Turbo C)回复于 2006-03-18 20:10:50 得分 10

请看SDK文档:  
   
   
   
   
  The   SendInput   function   synthesizes   keystrokes,   mouse   motions,   and   button   clicks.  
   
  Syntax  
   
  UINT   SendInput(UINT   nInputs,  
          LPINPUT   pInputs,  
          int   cbSize  
  );  
   
   
   
  Parameters  
   
  nInputs  
  [in]   Specifies   the   number   of   structures   in   the   pInputs   array.    
  pInputs  
  [in]   Pointer   to   an   array   of   INPUT   structures.   Each   structure   represents   an   event   to   be   inserted   into   the   keyboard   or   mouse   input   stream.    
  cbSize  
  [in]   Specifies   the   size,   in   bytes,   of   an   INPUT   structure.   If   cbSize   is   not   the   size   of   an   INPUT   structure,   the   function   will   fail.    
  Return   Value  
   
  The   function   returns   the   number   of   events   that   it   successfully   inserted   into   the   keyboard   or   mouse   input   stream.   If   the   function   returns   zero,   the   input   was   already   blocked   by   another   thread.  
   
  To   get   extended   error   information,   call   GetLastError.  
   
   
   
   
  Remarks  
   
  The   SendInput   function   inserts   the   events   in   the   INPUT   structures   serially   into   the   keyboard   or   mouse   input   stream.   These   events   aren't   interspersed   with   other   keyboard   or   mouse   input   events   inserted   either   by   the   user   (with   the   keyboard   or   mouse)   or   by   calls   to   keybd_event,   mouse_event,   or   other   calls   to   SendInput.  
   
  This   function   does   not   reset   the   keyboard's   current   state.   Any   keys   that   are   already   pressed   when   the   function   is   called   might   interfere   with   the   events   that   this   function   generates.   To   avoid   this   problem,   check   the   keyboard's   state   with   the   GetAsyncKeyState   function   and   correct   as   necessary.  
   
  Top

5 楼Mackz(在相互)回复于 2006-03-18 20:15:37 得分 15

按钮的Caption设置为"是(&Y)"Top

6 楼huaboy408(Thinking...)回复于 2006-03-18 20:16:25 得分 15

用PreTranslateMessage,截获Y键消息,然后用mouse_event模拟鼠标事件Top

相关问题

  • 屏蔽鼠标按键
  • 鼠 标 按 键 的 问 题
  • 如何模拟鼠标按键
  • 怎样判断 鼠标按键?
  • 鼠标按键状态的判断
  • 如何屏蔽鼠标按键
  • 怎样用SendMessage模仿按键Ctrl+V
  • 如何向开始菜单发送鼠标按键消息
  • 如何截获鼠标消息(按键,移动)?
  • 如何用程序模拟鼠标的按键活动

关键词

  • 鼠标
  • pinputs
  • cbsize
  • structure
  • mouse
  • input
  • events
  • function

得分解答快速导航

  • 帖主:du51
  • vcmute
  • iswjh
  • Mackz
  • huaboy408

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo