VB如何向指定窗口发送后台鼠标点击,窗口最小化后仍可工作?
VB如何向指定窗口发送后台鼠标点击,窗口最小化后仍可工作?
比如窗口句柄为A
怎么写向窗口A的某个点发送鼠标点击,要后台的,窗口A在最小化的情况下仍然可以点击到。麻烦写个原码!
请帮帮忙,最好有代码实例,满意后再加分
[解决办法]
最小化后貌似wndProc暂时不再处理键盘鼠标重绘等消息了?
所以我猜,你投递消息过去也是木有用滴....
[解决办法]
使用PostMessage.
Private Function SendClick(hwnd As Long, mX As Long, mY As Long) '发送点击消息 Dim I As Long I = PostMessage(hwnd, WM_LBUTTONDOWN, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000) I = PostMessage(hwnd, WM_LBUTTONUP, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000) End Function
[解决办法]
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 Const BM_CLICK = &HF5
Private Const MK_LBUTTON = &H1
'其中hwnd是被点击控件的句柄,X,Y就是要点击的坐标(以被点击控件为基础不是以屏幕为基础)
PostMessage hwnd, BM_CLICK, MK_LBUTTON, y * 65536 + x