【问题标题】:getting selected text in visual studio 2015 using autohotkey使用 autohotkey 在 Visual Studio 2015 中获取选定的文本
【发布时间】:2016-11-14 02:31:26
【问题描述】:

我想找到 // cmets 然后按 F4 ,它们转换为 /* */。 所以我需要使用 autohotkey 应用程序在 Visual Studio 2015 中获取选定的文本。 我使用 Active Windows Info (Window Spy) 来获取有关 Visual Studio 的一些信息,但它没有给我很好的信息,而且我无法在 VS 中获取选定的文本。 我需要用自动热键写这个。

【问题讨论】:

  • 你确定这不能在 VS 中完成吗?我的意思是.. 它是 Visual Studio
  • 它可以在 VS 中完成,但我想要一个 ahk,因为您可以在 VS 和其他 IDE 中使用它,也可以为许多应用程序使用一个宏

标签: c# visual-studio replace comments autohotkey


【解决方案1】:

终于找到了解决办法

F4::
TempCB = %ClipBoard%
ClipBoard = ; Clear clipboard
Send, ^c
Sleep, 100 ; Wait 0.1 seconds for clipboard (clipboard will not get filled if nothing is selected)
if (Clipboard = "")
{
    Send, {Home}+{End}^c ; Select line and copy to clipbard
}
SelectedLine = %ClipBoard%
pos := RegExMatch(SelectedLine,"\/\/",found)
if(found = "//"){
Str := RegExReplace(SelectedLine,"`r`n$","")
Str := RegExReplace(Str,"\/\/","/*")
Str .= " */"
Send, {Home}+{End}^x
ClipBoard = %Str%
Send, {Raw}%Str%
}
ClipBoard = %TempCB% ; Restore (text part) of previous clipboard content.
Return

【讨论】:

    【解决方案2】:

    我无法在 VS 中获取所选文本

    在活动应用程序中获取选定的文本通常在 Ahk 中是这样完成的:

    clipboard_backup := clipboardAll
    send ^c ; copy
    clipwait
    SELECTED_TEXT := clipboard
    clipboard := clipboard_backup
    

    没有明确测试过,但它应该给你一个想法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-30
      • 1970-01-01
      • 1970-01-01
      • 2016-10-11
      • 1970-01-01
      • 2017-06-28
      • 2015-07-21
      • 1970-01-01
      相关资源
      最近更新 更多