我如何使用 Dragon NaturallySpeaking 的高级脚本来驼峰式拼写短语?

How can I camelCase a phrase with Dragon NaturallySpeaking's advanced scripting?

有时,通常是在编码时,我想口述一个短语,以便它是驼峰式的短语。例如,当我听写 sentence generator 时,我希望 Dragon NaturallySpeaking 写 sentenceGenerator

如何使用 Dragon NaturallySpeaking 的高级脚本来驼峰式拼写短语?


Dragon Dictate 的相同问题:

您可以使用这个功能:

' 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)