search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   Writing a simple vb.net code and need assistance...

2/3/2006 12:46:18 PM    VS.NET extensibility: contents of Find Window?
I'm trying to get the contents of the Find Results window in a program  
  
that's intended to run from the Tools menu.  I've got as far as getting  
  
the Find Window object, but I can't figure out how to get the actual  
  
contents.  If I get the selection (which is exposed), the program does  
  
exactly what I want it to do.  How can I get the contents of the window  
  
regardless of selection?  
  
The actual functionality takes the list of filenames given by Find In  
  
Files and opens them for edit (i.e. "checks them out") in Perforce.  
  
Here's the code in Python; it should be easy enough to follow what's  
  
going on even if you don't know it:  
  
import re  
  
import p4  
  
import win32com.client  
  
FILENAME_REGEX = re.compile(r'^[a-zA-Z0-9 /\\:._]*(?=\(\d*\):)', re.M)  
  
def GetLines():  
  
devStudio = win32com.client.Dispatch('VisualStudio.DTE')  
  
findWindow =  
  
devStudio.Windows.Item(win32com.client.constants.vsWindowKindFindResults1)  
  
selection = findWindow.Selection()  
  
return selection  
  
result of "Find in Files" into a list.  
  
def BuildFileList(buffer):  
  
files = set()  
  
for match in FILENAME_REGEX.finditer(buffer):  
  
start = match.start()  
  
end = match.end()  
  
files.add(buffer[start:end])  
  
return files  
  
if __name__ == '__main__':  
  
p4c = p4.P4()  
  
p4c.connect()  
  
lines = GetLines()  
  
if not lines:  
  
print 'You must select the lines in the find window.  Sorry.'  
  
else:  
  
files = BuildFileList(lines)  
  
for file in files:  
  
print 'edit', file  
  
p4c.run_edit(str(file))  # the P4 api requires strings, but we get  
  
unicode from DevStudio  
  
print '\nDone.'  
  
p4c.disconnect()

2/6/2006 4:27:32 PM    Re: VS.NET extensibility: contents of Find Window?
I found the solution on  
  
http://www.dotnet247.com/247reference/msgs/30/151594.aspx  
  
My misunderstanding was that I was calling Window.Selection as a  
  
function, which was indeed giving me a string with the contents of the  
  
selection.  What I didn't know was that Window.Selection is a selection  
  
object, so I could in fact use it to manipulate the selection itself;  
  
select everything, grab a copy of the text, and then deselect.  
  
So, I have the following function:  
  
def GetLines():  
  
devStudio = win32com.client.Dispatch('VisualStudio.DTE')  
  
findWindow =  
  
devStudio.Windows.Item(win32com.client.constants.vsWindowKindFindResults1)  
  
selection = findWindow.Selection  
  
selection.SelectAll()  
  
text = selection.Text  
  
selection.Cancel()  
  
return text  
  
....and I'm good.  
  
Not sure if anyone here is interested in this, but thought I'd post if  
  
someone else tries searching for the answer like I did.  ;)


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.