vb 有关sendmessage和postmessage的问题。
PublicDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString...
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public 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
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CHAR = &H102
Sub Macro1()
Dim hwnd, hwnd1 As Long
hwnd = FindWindow(vbNullString, "无标题 - 记事本")
hwnd1 = FindWindowEx(hwnd, 0, "edit", vbNullString)
SendMessage hwnd1, WM_CHAR, 65, 0
End Sub
在excel宏里打了这个代码,是想在记事本输出一个字符a的,但一运行,他就不行的输a直到记事本死掉,请问代码有什么问题,应该怎么样才能够只输出一个字符?
可以复制代码试一下,真的是这样,求大神解答为什么和解决方案! 展开
Public 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
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CHAR = &H102
Sub Macro1()
Dim hwnd, hwnd1 As Long
hwnd = FindWindow(vbNullString, "无标题 - 记事本")
hwnd1 = FindWindowEx(hwnd, 0, "edit", vbNullString)
SendMessage hwnd1, WM_CHAR, 65, 0
End Sub
在excel宏里打了这个代码,是想在记事本输出一个字符a的,但一运行,他就不行的输a直到记事本死掉,请问代码有什么问题,应该怎么样才能够只输出一个字符?
可以复制代码试一下,真的是这样,求大神解答为什么和解决方案! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询