想使鼠标自动移动到指定一点(另一个程序的标题栏),然后点击左键SetCursorPos 5, 5
Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, GetMessageExtraInfo)
Call mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, GetMessageExtraInfo)鼠标可以移动到指定点,但不自动点击左键。因为另一程序的窗口并没有变成当前窗口。
Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, GetMessageExtraInfo)
Call mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, GetMessageExtraInfo)鼠标可以移动到指定点,但不自动点击左键。因为另一程序的窗口并没有变成当前窗口。
解决方案 »
- vb access数据库,insert插入语句,除了内容中有单引号外,还有什么字符会照成“字符串的语法错误,在查询表达式...”?
- 打印机功能实现?
- 关于FindWindowEx的一个疑惑,请热心朋友解答!!十万火急!!
- 高分求助vb如何与神龙卡3进行连接?
- adodc连接access的问题
- MSHFlexGrid1问题:运行后,提示我“下标越界”
- 谁用过这种方法,请帮忙调试一下
- 一个关于WAV转换成MP3的问题。
- 请问如何取得collection中某个item的key值?
- 急 ,如何把msflexgrid 中的数据保存到到数据库中呢?
- 怎样用VB自带的工具做打包,可以在安装的时候建一个系统数据源?
- 一个基础问题:如何正确显示MDI窗口的子窗口,为什么无论怎么调整子窗口大小都不变?
Dim lParam As Long
Dim LongInt As Long
LongInt = 65536
lParam = LongInt * y + x SendMessage Hwnd, WM_LBUTTONDOWN, 0&, lParam
SendMessage Hwnd, WM_LBUTTONUP, 0&, lParam
End Sub
http://www.sijiqing.com/vbgood/code/index.asp?glz=鼠标
http://vbclass.y365.com/jishu/yaokong.htm
Const NUM_MOVES = 3000
Dim pt As POINTAPI
Dim cur_x As Single
Dim cur_y As Single
Dim dest_x As Single
Dim dest_y As Single
Dim dx As Single
Dim dy As Single
Dim i As Integer ' Things are easier working in pixels.
ScaleMode = vbPixels
picClicker.ScaleMode = vbPixels ' mouse_event moves in a coordinate system where
' (0, 0) is in the upper left corner and
' (65535,65535) is in the lower right corner. ' Get the current mouse coordinates and convert
' them into this new system.
GetCursorPos pt
cur_x = pt.X * 65535 / ScaleX(Screen.Width, vbTwips, _
vbPixels)
cur_y = pt.Y * 65535 / ScaleY(Screen.Height, vbTwips, _
vbPixels) ' Convert the coordinates of the center of the
' picClicker PictureBox into this new system.
pt.X = picClicker.ScaleWidth / 2
pt.Y = picClicker.ScaleHeight / 2
ClientToScreen picClicker.hwnd, pt
dest_x = pt.X * 65535 / ScaleX(Screen.Width, vbTwips, _
vbPixels)
dest_y = pt.Y * 65535 / ScaleY(Screen.Height, vbTwips, _
vbPixels) ' Move the mouse.
dx = (dest_x - cur_x) / NUM_MOVES
dy = (dest_y - cur_y) / NUM_MOVES
For i = 1 To NUM_MOVES - 1
cur_x = cur_x + dx
cur_y = cur_y + dy
mouse_event _
MOUSEEVENTF_ABSOLUTE + _
MOUSEEVENTF_MOVE, _
cur_x, cur_y, 0, 0
DoEvents
Next i ' Move the mouse to its final destination and click it.
mouse_event _
MOUSEEVENTF_ABSOLUTE + _
MOUSEEVENTF_MOVE + _
MOUSEEVENTF_LEFTDOWN + _
MOUSEEVENTF_LEFTUP, _
dest_x, dest_y, 0, 0
End Sub
Dim P As POINTAPI
j=WindowFromPoint(P.x, P.y)
SendMessage j, WM_LBUTTONDOWN, 0,0
SendMessage j, WM_LBUTTONUP, 0,0当鼠标移动到本程序窗体内某一控件有效(如移动到command控件上),但当鼠标移动到本程序窗体外,另一程序窗体中则无效,另一程序的窗体并没有变成当前窗体。
SendMessage Hwnd, WM_LBUTTONUP, 0&, lParam方向肯定没有问题
你要用findwindow找到窗体句柄后,再用findwindowex找到按钮句柄,然后发送消息
SendMessage Hwnd, WM_LBUTTONUP, 0&, lParam
的确可以,不知前天是怎么搞的,就是不行,昨天一试就像大家所说的,可以了!
不说那么多了,给分了。