找回密码
 加入
搜索
查看: 5578|回复: 5

[AU3基础] 关于_WinAPI_PostMessage(已解决)

  [复制链接]
发表于 2010-9-21 09:31:04 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2010-9-21 13:55 编辑

谁知道应该怎么简化 这样每个字符需要1个命令 也太长了

-------------------------------
不要说用send 这样是为了突破输入法限制的
Dim Const $WM_CHAR = 0x102

Run('notepad.exe')
Opt('WinTitleMatchMode', 4)
WinWait("[CLASS:Notepad]", '', 10)
$hNote = WinGetHandle("[CLASS:Notepad]")
Opt('WinTitleMatchMode', 1)
$hEdit = ControlGetHandle($hNote, '', 'Edit1')

_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("w"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("w"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("w"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("."), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("b"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("a"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("i"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("d"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("u"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("."), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("c"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("o"), 0)
_WinAPI_PostMessage($hEdit, $WM_CHAR, Asc("m"), 0)

Func _WinAPI_PostMessage($hWnd, $iMsg, $iwParam, $ilParam)
        Local $aResult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hWnd, "uint", $iMsg, "wparam", $iwParam, "lparam", $ilParam)
        If @error Then Return SetError(@error, @extended, False)
        Return $aResult[0]
EndFunc

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-9-21 11:05:08 | 显示全部楼层
循环赛。。。。。
发表于 2010-9-21 13:02:53 | 显示全部楼层
回复 1# shenrenba

在剪切板中写入"www.baidu.com"
然后用Send("^v")粘贴剪切板中的内容,和你代码效果是一样的
Dim Const $WM_CHAR = 0x102

Run('notepad.exe')
Opt('WinTitleMatchMode', 4)
WinWait("[CLASS:Notepad]", '', 10)
$hNote = WinGetHandle("[CLASS:Notepad]")
Opt('WinTitleMatchMode', 1)
$hEdit = ControlGetHandle($hNote, '', 'Edit1')

ClipPut("www.baidu.com")
_WinAPI_PostMessage($hEdit, $WM_CHAR, Send("^v"), 0)

Func _WinAPI_PostMessage($hWnd, $iMsg, $iwParam, $ilParam)
        Local $aResult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hWnd, "uint", $iMsg, "wparam", $iwParam, "lparam", $ilParam)
        If @error Then Return SetError(@error, @extended, False)
        Return $aResult[0]
EndFunc   ;==>_WinAPI_PostMessage

评分

参与人数 2金钱 +30 贡献 +3 收起 理由
afan + 20 + 2
shenrenba + 10 + 1

查看全部评分

 楼主| 发表于 2010-9-21 13:43:51 | 显示全部楼层
回复 3# lixiaolong


    思路比我强 我就没想到  你这样直接突破了限制 连_WinAPI_PostMessage函数都不需要了
发表于 2010-9-21 14:24:02 | 显示全部楼层
学习学习!
发表于 2010-9-21 14:24:25 | 显示全部楼层
_WinAPI_PostMessage 这个函数我还没学过那,继续努力,可可
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 09:07 , Processed in 0.087285 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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