使用 autohotkey 在 visual studio 2015 中获取选定的文本

getting selected text in visual studio 2015 using autohotkey

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

终于找到解决方法

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

I couldn't get the selected text in the VS

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

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

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