473,654 Members | 3,089 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 4625
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 EnumChildWindow s 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.co m. 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
1899
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 how to get the selected text when this hotkey is pressed.
1
1687
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 holding a key down 3) My .NET application gets the selected text that was under the mouse cursor when the click was performed.
0
1023
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 holding a key down 3) My .NET application gets the selected text that was under the mouse cursor when the click was performed.
6
2132
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 "string" in google comp.lang.c archives.Hope this helps.Hope I am not bothering any one. am I? =================================Start=========================== subject: Return to Start of Line? Question: I'd like printf, the next printf, to return...
3
2650
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 as done by Babylone application. Regards, Joe
4
6128
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 extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub Page_Load(..........) Dim dSet As DataSet Dim sqlConn As SqlConnection
1
2782
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 with setting up system wide hotkeys and with copying selected text if it was not an external application but could not find any info on how I might do the above.
0
3563
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 the value of the selected menu item. Heres the XML datasource that I am using: <?xml version="1.0" encoding="utf-8" ?> <Home> <Menu text="Patient" description=" "> <SubMenu text="First Name" description="firstName"></SubMenu> ...
0
1337
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 Word.Application Dim wdoc As Word.Document wapp = GetObject(, "Word.Application")
0
8294
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,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8494
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
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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
6162
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
5627
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1924
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.