AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Search a Directory Tree Using Visual Studio 2005

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
tazmanian



Joined: 17 Nov 2007
Posts: 16

PostPosted: Mon Dec 31, 2007 9:00 pm    Post subject: Search a Directory Tree Using Visual Studio 2005 Reply with quote

Hi

The problem with the Windows built in find and replace is that it takes too long to find the text in files and it does not support Regex.

I wrote a fairly simple script which can be used to search a directory tree using Visual Studio. The aim is that you would have a right click a folder in Explorer and then click on "Find using Vs2005" and this would drop you into visual studio and the text box contains the directory you selected.

It is a simple script, but I hope you find it useful:

Code:

#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; A window's title can contain WinTitle anywhere inside it to be a match

Run, C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe ; The program we use to search files with
Loop, 50 ; Spend a maximum of 5,000ms = 5sec for Visual Studio to open for this purpose.
{
   IfWinExist Start Page - Microsoft Visual Studio ; It has finally loaded!
   {
      WinActivate, Start Page - Microsoft Visual Studio ; Activate the window
      Send, ^+f   ; Open the Find in Files dialog using this shortcut
      Sleep, 100  ; Sleep long enough so the find dialog can initialise
      if 0 > 0    ; If there is at least one argument
      {
         StringReplace, 1, 1, ",, All ; Remove trailing instances of quote " mark
         ControlSetText, Edit3, %1%, Find and Replace ; Set the Directory Text box to the argument
      }
      ControlFocus, Edit1, Find and Replace ; Set the focus to the string search box
      Break ; Break if we so all the above.
   }
   Sleep, 100


ExitApp

We also need need a registry entry which adds the context sensitive menu to the windows explorer:

Code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\FindVs2005]
@="Find using Vs2005"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\FindVs2005\command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"C:\\FindInFiles.ahk\" \"%L\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\FindVs2005]
@="Find using Vs2005"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\FindVs2005\command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"C:\\FindInFiles.ahk\" \"%L\""

Obviously replace C:\\FindInFiles.ahk to the path of the script.

-Tahir
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group