本帖最后由 segree 于 2023-5-20 18:23 编辑
如题:想通过vbs调用vba的api函数,已经在vba里面成功用上获取屏幕坐标颜色数值,想通过vbs脚本调用,不知道怎么调用- Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
- Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
- Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
- '********************** 类型声明 ****************************
- Private Type POINTAPI
- x As Long
- y As Long
- End Type
- Private Sub tmp2()
- Debug.Print Hex(pixcolour)
- End Sub
- Public Function pixcolour() As Long
- Dim pt As POINTAPI
- GetCursorPos pt
- Dim Dc: Dc = GetDC(0)
- pixcolour = GetPixel(Dc, pt.x, pt.y)
- End Function
- vbs:
- "Private Declare Function GetDC Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCrLf & _
- "Private Declare Function GetPixel Lib ""gdi32"" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long" & vbCrLf & _
- " Public Function pixcolour() As Long" & vbCrLf & _
- "Dim pt As POINTAPI: GetCursorPos pt" & vbCrLf & _
- "Dim Dc:Dc = GetDC(0)" & vbCrLf & _
- "pixcolour = GetPixel(Dc, pt.X, pt.Y)" & vbCrLf & _
- "End Function" & vbCrLf & _
复制代码 请问怎么用vbs调用vba的函数呀?vbs脚本上这么写封装的函数对吗?"ublic Function pixcolour() As Long" & vbCrLf & _ 这一行报错:缺少语句 1字符 800A0400 |