找回密码
 加入
搜索
查看: 2510|回复: 6

请问向指定窗口发送后台按键消息?

[复制链接]
发表于 2008-10-25 09:42:39 | 显示全部楼层 |阅读模式
列如我想向已经打开的Windows的画图工具发送ALT+I  和A的按键消息,应该怎么做啊?

[ 本帖最后由 s77m72 于 2008-10-28 15:53 编辑 ]
 楼主| 发表于 2008-10-25 11:06:10 | 显示全部楼层
没高手在吗?
发表于 2008-10-25 11:42:35 | 显示全部楼层
下面这个是新开一个mspaint, 向现有的发送的话,可以把run注释掉

AutoItSetOption("WinTitleMatchMode", 4)
$PID=run("mspaint.exe");
WinWait("classname=MSPaintApp");
$hWin=WinGetHandle("classname=MSPaintApp");
$hCanvas=ControlGetHandle($hWin,"","[classnn:Afx:1000000:81]");
ControlSend($hWin,"",$hCanvas,"{ALT}");
ControlSend($hWin,"",$hCanvas,"I");
ControlSend($hWin,"",$hCanvas,"A");
发表于 2009-5-11 23:42:15 | 显示全部楼层
请问楼上的大哥
$hCanvas=ControlGetHandle($hWin,"","[classnn:Afx:1000000:81]");
中的
classnn:Afx:1000000:81
是什么意思
发表于 2009-5-15 01:59:28 | 显示全部楼层
控件ID,看下帮助的函数说明
举个其他的例子
e.g. Send text to the 1st Edit control in the Notepad window

ControlSend("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", "This is some text")

or

ControlSend("Untitled - Notepad", "", "[CLASSNN:Edit1]", "This is some text")

or

ControlSend("Untitled - Notepad", "", "Edit1", "This is some text")
发表于 2009-8-28 00:48:52 | 显示全部楼层
如果要发送的窗口的控件时轻量控件,找不到句柄,而且API POSTMESSAGE函数也被屏蔽,有什么方法可以实现后台按键发送呀?
发表于 2011-10-28 01:55:36 | 显示全部楼层
恩,不错。对一般的窗口挺管用
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-1 12:22 , Processed in 0.077705 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表