postmessage的API函数不是明白是什么意思 也不会使用所以请各位高人求教下 第一先告我下是什么意思 具体是干什么的要白话 之后告我下任何使用 都有什么相应的函数 跪求了 先给20 回答好了一定加分
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_CHAR = &H102
Private Const VK_A = &H41
Function MakeKeyLparam(ByVal VirtualKey As Long, ByVal flag As Long) As Long
Dim s As String
Dim Firstbyte As String ''lparam参数的24-31位
If flag = WM_KEYDOWN Then ''如果是按下键
Firstbyte = "00"
Else
Firstbyte = "C0" ''如果是释放键
End If
Dim Scancode As Long
''获得键的扫描码
Scancode = MapVirtualKey(VirtualKey, 0)
Dim Secondbyte As String ''lparam参数的16-23位,即虚拟键扫描码
Secondbyte = Right("00" & Hex(Scancode), 2)
s = Firstbyte & Secondbyte & "0001" ''0001为lparam参数的0-15位,即发送次数和其它扩展信息
MakeKeyLparam = Val("&H" & s)
End Function
Private Sub Form_Load()
End Sub
Private Sub Timer1_Timer()
Dim Phwnd As Long
Dim hwnd As Long
Phwnd = FindWindow(vbNullString, "新建 文本文档.txt - 记事本")
If Phwnd = 0 Then
Text1.Text = "fill"
Else
Text1.Text = "phwnd"
End If
hwnd = FindWindowEx(Phwnd, 0, "edit", vbNullString)
If hwnd = 0 Then
Text2.Text = "fill"
Else
Text2.Text = "ChildHwnd"
End If
PostMessage hwnd, WM_KEYDOWN, VK_A, MakeKeyLparam(VK_A, WM_KEYDOWN) ''按下A键
PostMessage hwnd, WM_CHAR, Asc("你"), MakeKeyLparam(VK_A, WM_KEYDOWN)
PostMessage hwnd, WM_CHAR, Asc("好"), MakeKeyLparam(VK_A, WM_KEYDOWN)
PostMessage hwnd, WM_CHAR, Asc("啊"), MakeKeyLparam(VK_A, WM_KEYDOWN)
PostMessage hwnd, WM_CHAR, Asc("!"), MakeKeyLparam(VK_A, WM_KEYDOWN) ''输入字符A
PostMessage hwnd, WM_UP, VK_A, MakeKeyLparam(VK_A, WM_UP) ''释放A键
End Sub
这个自动向那个记事本发送文字,”你好啊!“可以在不是活动窗口的时候发送,也就是说可以在你用QQ和别人在聊天这个程序也会运行,不会干扰你和别人聊天。。~~
VB中SendMessage和postmessage的详细用法。
SendMessage : 发送一个消息给操作系统,并且等待操作系统执行完这个消息。postmessage : 发送一个消息给操作系统,不等待操作系统执行完这个消息就立即返回执行下一条语句。 SendMessage 定义:Public Shared Sub SendMessage ( _ ByRef m As Message _ ) SendMessage 调用: Dim m As Message...
vb中PostMessage怎么用?
例:游戏挂机,如果一个简单的游戏挂机只需要点击鼠标就可以,那我们就可以用VB做一个简单的外挂,用SetCursorPos()等函数把鼠标移动到指定的位置上点击,但这样的话,游戏界面就一定要在前台,但如果用postmessage()函数的话,就算是游戏已经最小化了,仍然可以将鼠标点击事件发送到游戏中,这就是postmessage的好...
VB postmessage的使用方法要详细
PostMessage hwnd, WM_KEYDOWN, VK_A, MakeKeyLparam(VK_A, WM_KEYDOWN) ''按下A键 PostMessage hwnd, WM_CHAR, Asc("你"), MakeKeyLparam(VK_A, WM_KEYDOWN)PostMessage hwnd, WM_CHAR, Asc("好"), MakeKeyLparam(VK_A, WM_KEYDOWN)PostMessage hwnd, WM_CHAR, Asc("啊"), Ma...
vb6.0 谁能详细的告诉我具体的使用PostMessage
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpW...
如何在VB中用PostMessage向指定窗口发送带有修饰键的组合键?
假设目标窗口的句柄已取得(hwnd),然后要用PostMessage向该窗口发送按键消息,对于普通字符键,直接用WM_CHAR消息最简单,如下:PostMessage hwnd, WM_CHAR, Asc("A"), 0 ' 发送一个 A 字符 对于非普通字符按键,如功能键、方向键等,要用 WM_KEYDOWN、WM_KEYUP 消息,如下:PostMessage ...
vb 怎么向一个窗口句柄发送一个回车键,就是按回车一次,但是呢,不能...
用API函数:sendmessage向窗口发送一个WM_KEYDOWN和WM_KEYUP详细就可以了。
VB Postmessage发送字符串问题
'一定要用SendMessageByString SendMessageByString& Text1.hwnd, WM_SETTEXT, 0, a 由于 postmessage 的处理机制 postmessage 向文本框发送 WM_SETTEXT 是成功不了的 PostMessage 功能:将一个消息放入(寄送)到与指定窗口创建的线程相联系消息队列里,不等待线程处理消息就返回。消息队列里的消息...
VB postmessage发送后台Tab
PostMessage hwnd,WM_CHAR,ASC("A"),MakeKeyLparam(VK_A,WM_KEYDOWN) '输入字符A PostMessage hwnd,WM_UP,VK_A,MakeKeyLparam(VK_A,WM_UP) '释放A键End Sub这就是通过局部键盘消息来模拟按键。这个方法有一个极大的好处,就是:它可以实现后台按键,也就是说他对你的前台操作不会有什么影响。比如,你可以...
VB postmessage 的用法急
第1,你定义了没有,2,你没加扫描码,后面不能为0 PostMessage hwnd,MakeKeyLpar(VK_A,WM_KEYDOWN)PostMessage hwnd,WM_UP,VK_A,MakeKeyLpar(VK_A,WM_KEYup)最好你能发出来看看,源码
在VB里面如何用postmessage函数向已知句柄的窗体发送单击鼠标的消息
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Sub Command1_Click()MsgBox...