Here is the code if anyone else is interested.
Paste the text below in Notepad and save it as FindTextPadKeyword.vbs
Change the value for TargetFileLocation and TextPadExe
Do a Search in files from Textpad with the "In folder"-field set to same value as TargetFileLocation and save it as Search Results.txt in same place as the vbs-file (not on TargetFileLocation)
Good luck
Henrik Andersen
www.cadcraft.se
' ==== VB Script File - Start =====
Dim Wshshell: Set WSHShell = WScript.CreateObject( "WScript.Shell" )
Dim Fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim Scriptpath: Scriptpath = fso.GetParentFolderName(WScript.ScriptFullName)
Dim WshSysEnv : Set WshSysEnv = WshShell.Environment("PROCESS")
Dim NoInstallMode: NoInstallMode = "NO"
Dim objArgs : set objArgs = Wscript.Arguments
TargetFileLocation = "C:\CAD\Cad_Anpassningar\seKonfigurator_2013"
TextPadExe = WshSysEnv("ProgramFiles(x86)") & "\Helios\TextPad4\TextPad.exe"
TextPadExe = "C:\_Runware\Text_Util\TextPad4\TextPad.exe"
If objArgs.Count = 0 Then
msgbox "No Argumets Attached"
else
for i = 0 to objArgs.Count -1
CmdLineArgs = CmdLineArgs & objArgs(i) & " "
next
End if
IF CmdLineArgs = "" THEN
strKeyWordname = inputbox ("Enter KeyWord", "","(defun ")
ELSE
strKeyWordname = inputbox ("Enter KeyWord", "", CmdLineArgs)
END IF
sFile = scriptpath & "\Search Results.txt"
Set oFile = FSO.GetFile(sFile)
If oFile.Size > 0 Then
Set oReadFile = FSO.OpenTextFile(sFile, 1)
Do While Not oReadFile.AtEndOfStream and FoundMatch = False
sText = oReadFile.ReadLine
if instr(1,sText, strKeyWordName,1) > 0 then
'msgbox "Found KeyWord" & sText
If Trim(sText) <> "" Then
startbracket = instr(sText, "(")
if startbracket > 0 then
endbracket = instr(startbracket + 1, sText, ")")
if endbracket>0 then
strTargetFile = mid(sText, 1, Startbracket-1)
strTextPos = mid(sText, Startbracket+1, Endbracket-Startbracket-1)
FoundMatch = True
End if
end if
End if
End if
Loop
oReadFile.close
if strTargetFile <> "" then
wshshell.run chr(34) & TextpadExe & chr(34) & " " & chr(34) & TargetFileLocation & "\" & strTargetFile & "(" & strTextPos & ",0)" ,1,false
else
msgbox "Failed to find keyword:" & CmdLineArgs & vblf & "in Search Result.txt"
End if
End if
' ==== VB Script File - End =====