是的,使用 '#Uses 指令将一组全局常量和函数合并到脚本中。
请参阅http://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/uses_comment.htm
因此,例如,我有一个全局文件,其中包含许多常量和函数,可以由任何开头的脚本使用:
'#Uses "C:\Scripts\pgGlobal.bas.txt"
您可以使用它来定义常量:
Public Const myWait = "0.3"
这只是一个函数及其关联的常量(但您也可以像上面一样自行定义常量):
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
' Use this function to get System parameters (screen, mouse, etc.)
'
Public Const SM_CXSCREEN = 0 ' The width of the primary display monitor.
Public Const SM_CYSCREEN = 1 ' The height of the primary display monitor.
Public Const SM_XVIRTUALSCREEN = 76 ' The left side of the virtual screen.
Public Const SM_YVIRTUALSCREEN = 77 ' The top of the virtual screen.
Public Const SM_CXVIRTUALSCREEN = 78 ' The width of the virtual screen.
Public Const SM_CYVIRTUALSCREEN = 79 ' The height of the virtual screen.
Public Const SM_CMONITORS = 80 ' The number of display monitors.
'
它被这样调用:
'#uses "C:\Scripts\pgGlobal.bas.txt"
Sub Main
MsgBox "Primary Width: " & GetSystemMetrics(SM_CXSCREEN) & _
" x Primary Height: " & GetSystemMetrics(SM_CYSCREEN) & vbCrLf & _
"Number of monitors: " & GetSystemMetrics(SM_CMONITORS) & vbCrLf & _
"Total Width: " & GetSystemMetrics(SM_CXVIRTUALSCREEN) & _
" x Total Height: " & GetSystemMetrics(SM_CYVIRTUALSCREEN) & vbCrLf & _
"Left Pixel: " & GetSystemMetrics(SM_XVIRTUALSCREEN) & _
" x Top Pixel: " & GetSystemMetrics(SM_XVIRTUALSCREEN)
End Sub
给我一个包含所有这些参数的消息框。