|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如果你会用大漠你就可以不用关心API了, 而且功能全套
'〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓★说★明★〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓☆〓〓'
'dm.dll, '添加以下代码在脚本最开始
'☆==========<函数>===========☆
Function dmRegist()
Dim ws, ver
Set ws = CreateObject("Wscript.Shell")
ws.run "regsvr32 d:\dm2.1126b\dm.dll /s"
Set ws = Nothing
delay 100
Set dm = CreateObject("dm.dmsoft")
ver = dm.ver()
If Len(ver) = 0 Then
dmRegist = 0
Exit Function
Else
dmRegist = 1
End If
End Function
'单击目标
Function LeftClickEx(x, y)
dm.Moveto x, y
dm.LeftClick
End Function
'★说★明★<窗口函数p1_4> *******☆***'
'函数简介: 获取顶层活动窗口中具有输入焦点的窗口句柄
'函数原型: long GetForegroundFocus()
'返回值: 返回整型表示的窗口句柄
'☆==========<函数>===========☆
Function GetForegroundFocusHwnd()
GetForegroundFocusHwnd = dm.GetForegroundFocus()
End Function
Sub 获得目标窗口坐标()
'>>>>>>>>>>>>>>>>>>>>>>>>>>
'[a3,4,5] 鼠标所在:顶层窗口句柄、鼠标所在目标句柄、焦点句柄
'[a6,7] 标题,内容
'[a8,9] 坐标、颜色
'[a10] 类
'[a11] 路径
'[a12] 获得窗口偏移量(窗口不移动则固定值)
'
'
Application.Calculation = xlCalculationManual
MsgBox "请切换到目标窗口,3秒后自动获取鼠标所在窗口信息。"
Dim h1, x, y, px, py
With Sheets("sap1")
delay 3000
dm1.dmRegist
dm1.SetWindowState3_5 h1, 12
'顶层、鼠标所在、焦点
.[a3] = dm1.GetForegroundWindowEx
.[a4] = dm1.GetMousePointWindowEx
.[a5] = dm1.GetForegroundFocusEx
'标题、内容
.[a6] = j7.GetWindowText(.[a3].Value)
.[a7] = j7.GetWindowText(.[a4].Value)
'坐标、颜色
dm1.GetCursorPosEx x, y
.[a8] = x & ", " & y
.[a9] = "RGB:" & dm1.GetColorRGB(x, y)
'类
.[a10] = dm1.GetWindowClassEx(.[a3].Value)
'路径
.[a11] = dm1.GetWindowProcessPathEx(.[a3].Value)
'获得窗口偏移量(窗口不移动则固定值)
dm1.ClientToScreenEx [a3].Value, px, py
.[a12].NumberFormat = "@"
.[a12] = x & "," & y
.Select
End With
'Application.WindowState = xlNormal
dm1.SetWindowState3_5 Application.hwnd, 12
MsgBox "信息获取完毕!"
Application.Calculation = xlCalculationManual
End Sub
|
评分
-
1
查看全部评分
-
|