473,796 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

manged alternative to get the complete text from each open window

i have a solution to gather the text in each window that is open, but would
rather use only managed code rather than unmanaged code my current solution
relies on. The purpose is to get the text in each open window
even/especially for child windows in other non managed mdi apps - if excel
has 3 books open or any other mdi app has several windows open, I'd like the
complete text from each window.

The current solution gives me more info than i need (quite a bit), as i'm
getting not just the text from each open window - i'm getting other stuff
that i am not familiar with with my desired info. heres the code i'm using
currently:

# Windows Form Designer generated code #

Private Delegate Function EnumWindowsProc ( _
ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32

Private Declare Function EnumWindows Lib "user32.dll " _
(ByVal lpEnumFunc As EnumWindowsProc , ByVal lParam As Int32) As Int32

Private Declare Function GetWindowTextLe ngth Lib _
"user32.dll " Alias "GetWindowTextL engthA" _
(ByVal hwnd As IntPtr) As Int32

Private Declare Function GetWindowText Lib "user32.dll " Alias
"GetWindowTextA " _
(ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32

Private Function EnumWindowsCall Back(ByVal hwnd As IntPtr, ByVal lParam As
Int32) As Int32

Dim sSave As String

sSave = Space(GetWindow TextLength(hwnd ) + 1)

GetWindowText(h wnd, sSave, Len(sSave))

sSave = Microsoft.Visua lBasic.Left(sSa ve, Len(sSave) - 1)

If sSave.Trim <> "" Then
lv.Items.Add(sS ave)
End If

Return 1
End Function

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button1.Click

lv.Items.Clear( )
EnumWindows(Add ressOf EnumWindowsCall Back, 0)

End Sub

Either a manged only alternative(per fect), a change to make to get only the
window text and not everythign else (a close second) or direction to go look
further (always appreciated) would be nice.

gabe
Nov 21 '05 #1
4 1804
Gabe,

You know this page?
http://msdn.microsoft.com/library/de...l/win32map.asp

I hope this helps,

Cor
Nov 21 '05 #2
Cor, darn i'm glad you responded, you've been invaluable in the past. yeah,
i spent the last 45 minutes staring at that exact page, checking
documentation for the classes and looking for samples (google, .net2themax,
et al) and while i see that the Win32 function GetWindowText is mapped to
System.Windows. Forms.Form.Text , I didnt see how that class could be used to
gather the window text for other/external programs and thier the window text
for mdiChildren. are you looking at another class or do i (again)
misunderstand that class, or are you using more than just that class?

gabe

"Cor Ligthert" wrote:
Gabe,

You know this page?
http://msdn.microsoft.com/library/de...l/win32map.asp

I hope this helps,

Cor

Nov 21 '05 #3
"gabe" <ga**@discussio ns.microsoft.co m> schrieb:
while i see that the Win32 function GetWindowText is mapped to
System.Windows. Forms.Form.Text , I didnt see how that class could be used
to
gather the window text for other/external programs and thier the window
text
for mdiChildren. are you looking at another class or do i (again)
misunderstand that class, or are you using more than just that class?


The 'Form' class is not a replacement of the Win32 API calls you mentioned
in your post. Some of the functionality you want to archieve can be
archieved using the 'System.Diagnos tics.Process' class and its
'GetProcesses' method and 'MainWindowTitl e' property, however, I doubt that
a fully managed solution is possible.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
bummer - really wish someone i respected less was telling that they doubted a
fully managed solution was possible, i saw the MainWindowTitle property and
thought maybe i had skipped over ChildWindowTitl es() or ChildWindow() on the
page, but no - just dont seem to exist. sadly, MainWindowTitle doesnt
provide what i'm looking for.

the solution is to run a db query based on some text found in another
process' childWindowTitl e, then start an additional process based on the
results of the query.
looks like i'm leaving in the win32api calls. oh well.

if you run my sample code you'll see that i get a bunch of entries that
arent visable windows?
can i somehow remove the entires that arent windows captions?

Aside from www.pinvoke.net, where do you go for vb.net win32api reference?
thanks tons
gabe
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
2400
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice or group of choices: Any J 81 J2 78 Any C 40 C1 29 Any D 9
2
1951
by: D. Alvarado | last post by:
Hello, Just wanted to check if this was possible. I have n blocks of text and I would like each to pop up in a window. Hoever, I don't want to create n different HTML pages and invoke each one through window.open. Is there some way I can call window.open and pass the text to it and have that text appear in the popup window? Styling is not important. I don't care if the text just appears in plain font. Thanks -
115
14193
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i prefer a solution that (also) supports Windows. On the net I found a number of products that i looked at, but none of them gave me the impression of a serious candidate at this moment (KNoda, Gnome DB Manager, InterBase...). 2 additional...
0
979
by: Monika Mesik | last post by:
I have made some progress toward creating very straight-forward UI for editing a non-hierarchical list of data without implementing a DataGrid. The UI needs to present the data for editing in textboxes, drop-down lists, check boxes, and radio buttons. ASP.NET Validation controls need to be part of this UI as well. I arranged the editing controls in a user control which I then placed in the ItemTemplate of a DataList control. I got the...
7
4472
by: Jared | last post by:
Hi I am using StateServer as my sessionState mode. I realise that I cannot use the Session_End in global.asax. I just want to do some simple logging of site usage. Has anybody got a simple solution that replaces the Session_End object? I was thinking of using client-side script to redirect to another page. I can then use this page to enter the information I require into the
1
3484
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select count_big(*) from sys.objects s1, sys.objects s2, sys.objects s3, sys.objects s4, sys.objects s5 PRINT GETDATE()
5
2268
by: Yashesh Bhatia | last post by:
Hello: I'm stuck with a small problem using windows created using javascript. Here's the code of the html file. ------------------------------------------------------------------------------------------------------ <html> <head> <title>Today's Date</title>
0
2042
by: hcuellar | last post by:
Hi. Please I need your help for this: After a database query, a table is created with a cell for each information retrieved, and for each record, two buttons, and second one have besides it an text imput field to asign this, open a mail client to send a mail to some people. All this, is made in php. In other words, user logs in, a window is open (after query) showing new appointments (set in other office), and each new appointment...
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.