gpt4 book ai didi

constants - Dragon NaturallySpeaking 的高级脚本中的全局常量

转载 作者:行者123 更新时间:2023-12-02 01:26:46 26 4
gpt4 key购买 nike

在 Dragon NaturallySpeaking 的高级脚本中,是否有任何方法可以定义可用于所有语音命令的常量?


例如,我有两个语音命令:

Sub Main
originalClipboard = Clipboard
Clipboard("~\cite{}")
SendKeys "^v"
Wait(0.3)
SendKeys "{LEFT}"
Clipboard(originalClipboard)
End Sub

Sub Main
Clipboard("os.path.join()")
SendKeys "^v"
Wait(0.3)
SendKeys "{Left}"
End Sub

我更愿意将 0.3 存储在全局常量中。

最佳答案

是的,使用 '#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

给我一​​个包含所有这些参数的消息框。

关于constants - Dragon NaturallySpeaking 的高级脚本中的全局常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36699140/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com