标题: [问题求助] vbs调用vba的api函数 [打印本页]
作者: segree 时间: 2023-5-20 18:10 标题: vbs调用vba的api函数
本帖最后由 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
作者: jyswjjgdwtdtj 时间: 2023-5-20 19:19
vbs里Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long这么些肯定是不对的
不过我不知道你是怎么调用vba的
作者: czjt1234 时间: 2023-5-20 19:48
http://demon.tw/programming/vbs-control-mouse.html
作者: jyswjjgdwtdtj 时间: 2023-5-20 21:10
嗯 demon.tw上的博客算是比较好的vbs……“攻略”?
作者: segree 时间: 2023-5-21 01:45
己解决怎么设置
作者: segree 时间: 2023-5-21 11:09
czjt1234 发表于 2023-5-20 19:48
谢谢指点,原来也有收藏,没仔细看,已做成vba函数从vbs调用。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |