-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenCodeLink.ahk
56 lines (49 loc) · 1.54 KB
/
OpenCodeLink.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#Requires AutoHotkey >=2.0
#SingleInstance Force
#Warn All, Off
if not A_IsAdmin
Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '"'
; http://msdn.microsoft.com/en-us/library/envdte.textselection.aspx
; http://msdn.microsoft.com/en-us/library/envdte.textselection.movetodisplaycolumn.aspx
VST_Goto(Filename, Row:=1, Col:=1) {
DTE := ComObjActive("VisualStudio.DTE")
DTE.ExecuteCommand("File.OpenFile", Filename)
DTE.ActiveDocument.Selection.MoveToDisplayColumn(Row, Col)
}
UND_Goto(Filename, Row:=1, Col:=1) {
UND_PATH := "C:\Program Files\SciTools\bin\pc-win64\understand.exe -visit "
Run UND_PATH Filename " " Row
}
MyGui := Gui()
MyGui.Add("Text", "Section", "CodeLink:") ; Save this control's position and start a new section.
CLink := MyGui.Add("Edit", "w460 r1") ; Add a fairly wide edit control at the top of the window.
Target := MyGui.AddComboBox("vTarget", ["VisualStudio","Understand"])
MyGui.Add("Button", "Default", "OK").OnEvent("Click", OK_Click)
OK_Click(*)
{
Link := CLink.Value
match := []
if RegExMatch(Link, "codelink://(.+):(\d+)", &match)
{
filePath := match[1]
lineNumber := match[2]
if Target.Value == "1" {
VST_Goto(filePath, lineNumber)
} else if Target.Value == "2" {
UND_Goto(filePath, lineNumber)
}
}
else
{
MsgBox("The input format is incorrect.")
}
MyGui.Hide()
}
; Hotkey: Win + G
#G::
{
ClipSaved := A_Clipboard
CLink.Value := ClipSaved
MyGui.Show("w480 h200")
return
}