如何用sendmessage向记事本发消息,让它弹出字体编辑框

 我来答
兆潇修1569
2017-07-28 · 超过17用户采纳过TA的回答
知道答主
回答量:112
采纳率:0%
帮助的人:25.7万
展开全部
'新建一个abc.txt文件并打开,测试正常Option Explicit
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32 " Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_SETTEXT = &HC
Private Sub Command1_Click()
Dim s As String, myhwnd As Long
s = Text1
myhwnd = FindWindow(vbNullString, "abc.txt - 记事本")
myhwnd = FindWindowEx(myhwnd, 0&, "Edit", vbNullString) '控件名用spy++查看,这里是Edit,特定的软件控件名都是固定的
If myhwnd = 0 Then
MsgBox "!!"
Exit Sub
End If
SendMessage myhwnd, WM_SETTEXT, 0, ByVal s
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式