473,505 Members | 15,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Selected Text from other application

29 New Member
Howdy!
I need a bit of direction...
I am in need (as the title suggests) of a way to get the selected text from any application. Of course, I understand I will need to get the application's handle, but that's no problem. I'm just not sure how I would go about getting the text after that. Is there an API that would help? This should work for all selected text in nearly all applications (Word, Works, Excel, IE, etc.).
I've seen it done before so I know that it's possible, I'm just not sure where to go next...

Thanks in advance!
May 17 '07 #1
6 4603
AdrianH
1,251 Recognized Expert Top Contributor
Howdy!
I need a bit of direction...
I am in need (as the title suggests) of a way to get the selected text from any application. Of course, I understand I will need to get the application's handle, but that's no problem. I'm just not sure how I would go about getting the text after that. Is there an API that would help? This should work for all selected text in nearly all applications (Word, Works, Excel, IE, etc.).
I've seen it done before so I know that it's possible, I'm just not sure where to go next...

Thanks in advance!
I'm not sure as to what you mean. Are you going to randomly go to different task windows and get the selected text in them? This doesn't make sense to me.

You can read the clipboard. But that is an entirly different question.

Could you clarify please.


Adrian
May 17 '07 #2
Banfa
9,065 Recognized Expert Moderator Expert
Of course, I understand I will need to get the application's handle, but that's no problem. I'm just not sure how I would go about getting the text after that.
Having the application Window handle would not be good enough, you would need the handle of the actual window containing the text (at the very least).

To understand what I have just said you need to understand that everything is a Window, when you see an editbox that editbox is, in fact, a window with a very specialised style. If you had the handle of the edit box window then you could request the selected text from it.

When you view an application like Word then you are seeing many windows, there is the main frame window, this contains a window for the toolbar area, which contains a window for each tool bar which in turn contain a window for each button. Then there is also a window for the client area (where the text is drawn) and probably sub windows with-in that.

It is possible to walk the window list of an application starting from the top most frame window using EnumChildWindows but then you would have to try and ascertain if each window enumerated had selected text and if it was the text you where interested in.

It sounds to me like you have set yourself quite a hard task if it is indeed possible.
May 17 '07 #3
cbbibleboy
29 New Member
No, I know about the windows and such--I'm very experienced with low level window control (Win32, no MFC). I know I would need the child window, and again, that would be no problem.

I've seen it (getting selected text) done before though, so I know it's possible.

I just need to know how...
May 17 '07 #4
AdrianH
1,251 Recognized Expert Top Contributor
No, I know about the windows and such--I'm very experienced with low level window control (Win32, no MFC). I know I would need the child window, and again, that would be no problem.

I've seen it (getting selected text) done before though, so I know it's possible.

I just need to know how...
Go to sysinternals.com. They had a lot of stuff there pretaining to window tools and development before being bought out by M$. They may have what you need.

EDIT: If you find what you are looking for, perhaps you could post back here and let us know. I would be interested in your findings.



Adrian
May 17 '07 #5
Banfa
9,065 Recognized Expert Moderator Expert
I've seen it (getting selected text) done before though, so I know it's possible.

I just need to know how...
I suspect a combination of the WM_GETTEXT and EM_GETSEL messages.
May 17 '07 #6
JohnTravolta
1 New Member
I suspect a combination of the WM_GETTEXT and EM_GETSEL messages.
<snipped> or <snipped> might do the same job but they are not free (LOL).
May 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1873
by: Nitesh Jain | last post by:
I want to write a simple utility, so that if I select a text, and press a hot key say (CTRL+ALT+G), then I should be able to open a google search page with the selected text. Could someone tell me...
1
1675
by: MS | last post by:
Hi, Does anyone know how to get selected text outside the .NET application? For instance: 1) In Internet Explorer, MS Excel or any other, I select some text 2) I perform a mouse click...
0
1011
by: MS | last post by:
Hi, Does anyone know how to get selected text outside the .NET application? For instance: 1) In Internet Explorer, MS Excel or any other, I select some text 2) I perform a mouse click...
6
2118
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
3
2645
by: [Joe] | last post by:
Hi all, I am wondering if there is anyway, I could detect if some text gets selected by the user in an external application. To give you an example, I would like to get the selected text same way...
4
6116
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
1
2773
by: macrow | last post by:
Hi All, I was wondering if it was possible in vb.net to select text from an external application such as IE, then press a hotkey which would copy the contents to clipboard? I have no problems...
0
3549
by: rehanmomin | last post by:
Just to start off, I am writing a web application using C#. I have a Menu which is binded to an XML datasource. There are three menu items each with submenus and a textbox where I want to display...
0
1327
by: darith | last post by:
Hello all, I want vb.net code to get selected text from Ms word. Could you kindly help me? For example, Imports Microsoft.Office.Core Imports Microsoft.Office.Interop Dim wapp As...
0
7218
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,...
0
7103
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...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5035
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...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
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...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.