SendMessage发送鼠标事件不成功,麻烦帮我看下问题出在哪里

问题描述

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Runtime.InteropServices;namespaceWindowsFormsApplication17{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}[DllImport("user32.dll")]staticexternIntPtrFindWindow(stringstrClass,stringstrWindow);[DllImport("user32.dll")]staticexternIntPtrFindWindowEx(IntPtrhwndParent,IntPtrhwndChildAfter,stringstrClass,stringstrWindow);[DllImport("user32.dll",EntryPoint="SendMessage")]privatestaticexternintSendMessage(IntPtrHwnd,intwMsg,intdwFlags,intdwExtraInfo);privateIntPtrSubFindWindowEx(IntPtrhwnd){IntPtrfindHwnd=FindWindowEx(hwnd,IntPtr.Zero,"CtrlNotifySink","");if(findHwnd!=IntPtr.Zero){IntPtrnoHwnd=FindWindowEx(findHwnd,IntPtr.Zero,"Button","否(&N)");if(noHwnd!=IntPtr.Zero){returnnoHwnd;}else{returnFindWindowEx(hwnd,IntPtr.Zero,"CtrlNotifySink","");}}returnIntPtr.Zero;}privatevoidbutton2_Click(objectsender,EventArgse){constintBM_CLICK=0xF5;IntPtrmaindHwnd=FindWindow(null,"注册表编辑器");IntPtrDirectUIHWND=FindWindowEx(maindHwnd,IntPtr.Zero,"DirectUIHWND","");IntPtrnoHwnd=SubFindWindowEx(DirectUIHWND);if(noHwnd!=IntPtr.Zero){SendMessage(noHwnd,BM_CLICK,0,0);}else{MessageBox.Show("没有找到No按钮");}}}}

这个模拟按键是,在运行了一个.reg文件时,弹出一个对话框的“否”按钮发送鼠标单击可是,findwindowex可以找到button,但是sendmesssage好像无效,大家帮忙看看问题在哪里?

解决方案

解决方案二:
加个断点,看下执行了没

时间: 2024-08-03 21:01:29

SendMessage发送鼠标事件不成功,麻烦帮我看下问题出在哪里的相关文章

注解-麻烦帮我看下SSH整合遇到的问题

问题描述 麻烦帮我看下SSH整合遇到的问题 最近公司要用SSH注解开发 我做了个小demo但是导入Easy UI的时候出现这个错误 解决方案 看样子是你代码里的EasyUI的引入路径写错了.可以把代码贴出来看下. 解决方案二: <link rel="stylesheet" type="text/css" href="/EasyUI/themes/default/easyui.css"> <link rel="style

点击事件-求大神帮我看下Fragment的问题

问题描述 求大神帮我看下Fragment的问题 问题是这样的我在一个FragmentA中点击listview的一个item跳到FragmentB中(replace方法),在B中的布局中点击仍然可以相应FragmentA中listview中的点击事件是什么情况?急急急 解决方案 哥们你这描述的太模糊了,贴代码上来看看. 解决方案二: 找到了,是布局的问题正在改中,谢谢哈

用asp.net弄了一个视频播放,用了以下代码画面出来却停在那里点击开始按钮也一直不播放,求大神帮我看下问题出现在那里?非常感谢!

问题描述 publicpartialclassPlay:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(Request.QueryString["url"]!=null)}}publicstringPlayMedia(){stringurl=Request.QueryString["url"].ToString();stringstrScript="<TABL

ExtJs的Combox从后台获取数据无法显示出来,请大虾们帮我看下!

问题描述 前台js代码var projectStore = new Ext.data.JsonStore({ url : 'http://localhost:8080/HyitSystem/provinceData.action',//这里是数据源,这地方我用的ajax映射到后台的service方法,返回上面的JSON串数据 root : 'value',//这里的value对应上传JSON串中的value fields : ['id','province']//这里的两个变量也分别对应上面JS

oracle trc 文件-各位数据大神麻烦帮我分析下这个oracle的trc文件,最大游标数设置的为1000

问题描述 各位数据大神麻烦帮我分析下这个oracle的trc文件,最大游标数设置的为1000 *** 2014-01-10 09:52:31.526*********START PLSQL RUNTIME DUMP************Got internal error Exception caught in pl l run-time while running PLSQLGot ORA-1000 while running PLSQLPACKAGE BODY FPM.GET_PARAME

web工程发布到新浪sae上出现503错误,麻烦帮我看一下JVM 日志

问题描述 web工程发布到新浪sae上出现503错误,麻烦帮我看一下JVM 日志 [29/Nov/2014:17:08:30 +0800] JAVA_Error: Failed startup of context c.s.s.w.SaeWebAppContext{/wuareyoung-1file:/data1/jetty_work/671/wuareyoung/jetty-0.0.0.0-12907-wuareyoung.war-_wuareyoung-1-any-/webapp/}/dat

求助-哪位好心人帮我看下代码吧,深度遍历搜索图的,有点长,麻烦看下吧

问题描述 哪位好心人帮我看下代码吧,深度遍历搜索图的,有点长,麻烦看下吧 //深度遍历搜索图 #include #include #define MAX_VERTEX_NUM 3 typedef enum {DG,DN,UDG,UDN} GraphKind;//图的类型 typedef int OtherInfo; //弧的信息,如权 typedef char VertexData;//图结点的内容为char typedef struct ArcNode { int adjvex; struct

各位大大,谁能帮我看下我这个spring3.0 和 mybatis整合出了什么问题呀,mybatis总是行不成功,完整项目我已经放在附件中了

问题描述 附件是我的项目,可以直接在eclipse中部署运行,用的mysql数据库,只需建一个test数据库就可以,建表语句在test.rar附件中,执行的service url是:http://localhost:8080/springTest/lyang/getAll.do每次一执行就报:java.lang.NullPointerExceptionat com.lyang.springTest.daoImpl.IPeopleDao.getAllPeople(IPeopleDao.java:1

ajax-求大神帮我看下为啥这段代码一直走error?

问题描述 求大神帮我看下为啥这段代码一直走error? 解决方案 跨域的服务器进行跨域支持了吗? 120.27.130.65这个服务器要支持你的跨域,才能使用jsonp,否则将不能回调到success函数. 跨域的本质是利用script,img等支持跨域的标签来对非同域名的链接来进行访问. 所以如果想要跨域成功,那么需要在调用方支持跨域. 我自己负责的很多项目跨域是自己写的实现,所以调用跨域的方法都得使用我封装的形式,否则默认是支持不了跨域的. jQuery的jsonp也一样,没有服务器是天然支