我怎么能用Dragon NaturallySpeaking的高级脚本编写一个短语?

时间:2017-06-05 22:46:11

标签: camelcasing naturallyspeaking

有时,通常在编码时,我想指定一个短语,以便它是camelCased一个短语。例如,当我指示sentence generator时,我希望Dragon NaturallySpeaking写sentenceGenerator

我怎么能用Dragon NaturallySpeaking的高级脚本来表达一个短语?

Dragon Dictate的相同问题:How can I convert a series of words into camel case in AppleScript?

1 个答案:

答案 0 :(得分:1)

您可以使用此功能:

' CamelCases the previous <1to10> words:
' Voice command name: CamelCase <1to10>
' Author: Edgar
' URL: https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' URL mirror: https://web.archive.org/web/20170606015010/https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' Tested with Dragon NaturallySpeaking 12.5 with Windows 7 SP1 x64 Ultimate

Sub Main
   Dim camelVariable, dictate, firstCharacter As String
   Dim wasSpace, isLower, trailingSpace As Boolean
   Dim dictationLength As Integer

   For increment = 1 To Val (ListVar1)
      SendKeys "+^{Left}", 1
   Next increment
   Wait 0.2
   SendKeys "^c", 1
   Wait 0.3
   dictate = Clipboard
   Wait 0.3
   dictationLength = Len (dictate)

   If Mid (dictate, dictationLength, 1) = " " Then trailingSpace = True
'Dim testing As String
'testing = "#" + Mid (dictate, 1, dictationLength) + "#"
'MsgBox testing
   dictate = Trim (dictate)
   firstCharacter = Mid (dictate, 1, 1)
   firstCharacter = LCase (firstCharacter)
   camelVariable = firstCharacter

   dictationLength = Len (dictate)
   If dictationLength > 1 Then
      For increment = 2 To dictationLength
         firstCharacter = Mid (dictate, increment, 1)
         If firstCharacter = " " Then
            wasSpace = True
         Else
            If wasSpace = True Then firstCharacter = UCase (firstCharacter)
            camelVariable = camelVariable + firstCharacter
            wasSpace = False
         End If
      Next increment
   End If
   If leadingSpace = True Then camelVariable = " " + camelVariable
   If trailingSpace = True Then camelVariable = camelVariable + " "
   SendKeys camelVariable
End Sub

' CamelCases the previous dictated words:
' Voice command name: CamelCase that
' Author: Heather
' URL: https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' URL mirror: https://web.archive.org/web/20170606015010/https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' Tested with Dragon NaturallySpeaking 12.5 with Windows 7 SP1 x64 Ultimate

Option Explicit

Sub Main
Dim engCtrl As New DgnEngineControl
Dim Text As String
Dim VarText As String

HeardWord "cut","that"
Text = Clipboard

SendDragonKeys "" & CamelCase(Text)
End Sub

Public Function CamelCase(strInput As String) As String
Dim i As Integer
Dim sMid As String
Dim foundSpace As Boolean

For i = 1 To Len(strInput)
sMid = Mid(strInput, i, 1)
Select Case Asc(sMid)
Case 32:
foundSpace = True

Case 65 To 90:

If i = 1 Then
CamelCase = CamelCase + LCase(sMid)
Else
CamelCase = CamelCase + sMid
End If

foundSpace = False

Case 97 To 122:
If foundSpace Then
CamelCase = CamelCase + UCase(sMid)
Else
CamelCase = CamelCase + sMid
End If

foundSpace = False

Case Else:
CamelCase = CamelCase + sMid
foundSpace = False

End Select
Next i
End Function

' CamelCases the next dictated words:
' Voice command name: CamelCase <dictation>
' Author: Edgar
' URL: https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' URL mirror: https://web.archive.org/web/20170606015010/https://www.knowbrainer.com/forums/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Linear&catid=12&threadid=14634&discTab=true
' Requires Dragon NaturallySpeaking 13 Professional or higher, because the variable <dictation> was introduced in Dragon NaturallySpeaking 13 Professional.

Sub Main
   Dim camelVariable, dictate, firstCharacter As String
   Dim wasSpace, isLower As Boolean
   Dim dictationLength As Integer

   dictate = ListVar1

   dictate = Trim (dictate)' probably unnecessary
   firstCharacter = Mid (dictate, 1, 1)
   firstCharacter = LCase (firstCharacter)
   camelVariable = firstCharacter

   dictationLength = Len (dictate)
   If dictationLength > 1 Then
      For increment = 2 To dictationLength
         firstCharacter = Mid (dictate, increment, 1)
         If firstCharacter = " " Then
            wasSpace = True
         Else
            If wasSpace = True Then firstCharacter = UCase (firstCharacter)
            camelVariable = camelVariable + firstCharacter
            wasSpace = False
         End If
      Next increment
   End If

   SendKeys " " + camelVariable + " "
End Sub

source)(mirror