VB 对窗口发送按键模拟
取到记事本窗口句柄对记事本发送按键消息用sendmessagehwd,&H100,VK_1,0这句应该对吧?但是无法实现对窗口的消息发送在本地使用Postmessaget...
取到记事本窗口句柄对 记事本发送按键消息
用sendmessage hwd,&H100,VK_1,0
这句应该对吧?但是无法实现对窗口的消息发送在本地
使用 Postmessage text1.hwnd,&H100,VK_1,0 可以在text1中发送 按键消息换到对窗口进行就无效了 请高手指点,不要用 sendkey哦 谢谢
3楼的 你要的可以达到关闭记事本的功能,我想在问下 我要用sendmessage hwnd,&H100,VK_1,0 发送按键消息为什么记事本中就没有显示呢 谢谢? 展开
用sendmessage hwd,&H100,VK_1,0
这句应该对吧?但是无法实现对窗口的消息发送在本地
使用 Postmessage text1.hwnd,&H100,VK_1,0 可以在text1中发送 按键消息换到对窗口进行就无效了 请高手指点,不要用 sendkey哦 谢谢
3楼的 你要的可以达到关闭记事本的功能,我想在问下 我要用sendmessage hwnd,&H100,VK_1,0 发送按键消息为什么记事本中就没有显示呢 谢谢? 展开
2个回答
展开全部
“无法实现对窗口的消息发送在本地”是指?如果能获得当前记事本的hwnd,我觉得应该能满足的你的需求。
找到notepad.exe(就是记事本),并关闭它的代码。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow("notepad", vbNullString)
SendMessage hwnd, WM_CLOSE, True, 0
End Sub
找到notepad.exe(就是记事本),并关闭它的代码。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow("notepad", vbNullString)
SendMessage hwnd, WM_CLOSE, True, 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询