【问题标题】:Copy the title of the active window to the clipboard in Microsoft Windows in Dragon NaturallySpeaking's advanced scripting在 Dragon NaturallySpeaking 的高级脚本中将活动窗口的标题复制到 Microsoft Windows 中的剪贴板
【发布时间】:2016-07-22 05:21:45
【问题描述】:

在Dragon NaturallySpeaking的高级脚本中,有没有办法将活动窗口的标题复制到Microsoft Windows中的剪贴板?

我使用的解决方法是定义一个AutoHotkey 脚本:

^!l::
WinGetActiveTitle, Title
Clipboard = %Title%
return

并在语音命令中调用键盘快捷键:

但我宁愿不必在 AutoHotkey 和 Dragon NaturallySpeaking 之间混杂。可以在“纯”高级脚本中完成吗?

【问题讨论】:

  • 答案是肯定的(我会尽快发布),但与此同时,您可以使用高级脚本调用 AHK 脚本,使用“ShellExecute”来运行 AHK 脚本,而无需触发任何热键 (你甚至可以传递 AHK 一些命令行参数)。查看knowbrainer.com/forums/forum/…(请注意,PG LTU 是我)。
  • @PGilm 谢谢,很高兴知道!

标签: naturallyspeaking


【解决方案1】:

是的,您可以使用 Dragon NaturallySpeaking 的高级脚本将活动窗口的标题复制到剪贴板,如下所示:

'
'   get window title
'
Sub Main
    Clipboard ( GetWindowTitle )
End Sub
'
'   Use these Windows Functions for Getting an active Window title
'
Declare Function GetForegroundWindow Lib "user32" () As Long
'
Declare Function GetWindowText Lib "user32" _
    Alias "GetWindowTextA" ( ByVal hwnd As Long , _
        ByVal lpString As String , ByVal cch As Long ) As Long
'
'   GetWindowTitle
'   (Gets an active Window title)
'
Function GetWindowTitle() As String
    Dim x As Integer
    Dim TitleText As String * 300
    Dim hw As Long
    hw = GetForegroundWindow()
    x = GetWindowText ( hw , TitleText , Len ( TitleText ) )
    GetWindowTitle = Trim ( Left ( TitleText , x ) )
End Function
'

现在,我将所有函数保存在一个全局 '#Uses 文件中(以及其他声明、函数和全局常量等),所以我只需要 Main Sub 部分,但您可以将所有引用的函数和在你需要的一个脚本中声明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    相关资源
    最近更新 更多