 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Born Guest
|
Posted: Fri Jan 06, 2006 10:49 pm Post subject: Getting the text under the cursor from any application |
|
|
Hi,
I attached a hotkey to my application.
I want to retrieve the string where the cursor is in when the hotkey
was pressed.
For instance. You are typing in MSWord. When you press the hotkey the
word you are typing should be available in my app.
I can get it to work when the text is already selected. Then i do a
wm_copy in the window and Clipboard.AsText in Delphi. But what if the
text was not already selected.
:)
Best whishes
Born
|
|
| Back to top |
|
 |
Andreas Koch Guest
|
Posted: Sat Jan 07, 2006 11:44 am Post subject: Re: Getting the text under the cursor from any application |
|
|
Born wrote:
| Quote: | I attached a hotkey to my application.
I want to retrieve the string where the cursor is in when the hotkey
was pressed.
|
Make a screenshot and then do an OCR (optical character recognition).
Thats the only way to work with every application.
|
|
| Back to top |
|
 |
etherington19@aol.com Guest
|
Posted: Sun Jan 08, 2006 10:59 am Post subject: Re: Getting the text under the cursor from any application |
|
|
Andreas Koch wrote:
| Quote: | Born wrote:
I attached a hotkey to my application.
I want to retrieve the string where the cursor is in when the hotkey
was pressed.
Make a screenshot and then do an OCR (optical character recognition).
Thats the only way to work with every application.
|
Hi
Is this really feasible. I would like to scrape data from the screen
but I didn't think that OCR was up to it. Any suggestions for OCR
packages that dont cost the earth (or even shareware)
Thanks
Ron Etherington
|
|
| Back to top |
|
 |
Delphi Fan Guest
|
Posted: Mon Jan 09, 2006 11:32 am Post subject: Re: Getting the text under the cursor from any application |
|
|
Does your application need to work with ANY other application, or will
the other app always be Word ?
If its Word, then have a look at Word automation. If not then you could
try logging all keystrokes then just look at your log to see what was
last typed.
I am also intrigued by the OCR idea - I have some apps that would
benefit from knowing what is going on in another app. Presumably your
app would need to find where the insertion cursor was on the screen and
look at the text to the left of this. Sounds like an interesting
challenge.
|
|
| Back to top |
|
 |
Andreas Koch Guest
|
Posted: Mon Jan 09, 2006 5:47 pm Post subject: Re: Getting the text under the cursor from any application |
|
|
[email]etherington19 (AT) aol (DOT) com[/email] wrote:
| Quote: | Is this really feasible.
Well, its the only way if you want to be able to handle every app. |
If an app displays its text by rendering it into a bitmap, its no
text anymore. How do you want to get that text back? You can get
certain things working with getwindowtext etc, but that won't help
for all apps.
| Quote: | I would like to scrape data from the screen
but I didn't think that OCR was up to it. Any suggestions for OCR
packages that dont cost the earth (or even shareware)
Well, if its only computer typed screen fonts, it should be doable to |
write your own, especially if you know what font type and size is used.
If not, you'd need some clever way to reduce needed tests...
|
|
| Back to top |
|
 |
Paul Dunn Guest
|
Posted: Tue Jan 10, 2006 1:46 pm Post subject: Re: Getting the text under the cursor from any application |
|
|
Andreas Koch wrote:
| Quote: | etherington19 (AT) aol (DOT) com wrote:
Is this really feasible.
Well, its the only way if you want to be able to handle every app.
If an app displays its text by rendering it into a bitmap, its no
text anymore. How do you want to get that text back? You can get
certain things working with getwindowtext etc, but that won't help
for all apps.
|
My own flagship app, BASin (an IDE for a BASIC language, written in Delphi)
doesn't display any system text in the editor - it's *all* bitmapped. You'd
need to get access to BASin's memory to pull the text out, and even then
it's not actually stored as text, but tokens.
So yes, OCR is the *only* way.
D.
|
|
| Back to top |
|
 |
Nicholas Sherlock Guest
|
Posted: Tue Jan 10, 2006 9:48 pm Post subject: Re: Getting the text under the cursor from any application |
|
|
Paul Dunn wrote:
| Quote: | My own flagship app, BASin (an IDE for a BASIC language, written in Delphi)
doesn't display any system text in the editor - it's *all* bitmapped. You'd
need to get access to BASin's memory to pull the text out, and even then
it's not actually stored as text, but tokens.
So yes, OCR is the *only* way.
|
For applications like these you could possibly get really creative and
hook TextOut with Madshi.net's MadHook.
Cheers,
Nicholas Sherlock
|
|
| Back to top |
|
 |
Paul Dunn Guest
|
Posted: Tue Jan 10, 2006 11:35 pm Post subject: Re: Getting the text under the cursor from any application |
|
|
Nicholas Sherlock wrote:
| Quote: | Paul Dunn wrote:
My own flagship app, BASin (an IDE for a BASIC language, written in
Delphi) doesn't display any system text in the editor - it's *all*
bitmapped. You'd need to get access to BASin's memory to pull the
text out, and even then it's not actually stored as text, but tokens.
So yes, OCR is the *only* way.
For applications like these you could possibly get really creative and
hook TextOut with Madshi.net's MadHook.
|
Would that actually work?
As I don't call any text routines - I declare a graphical surface and then
write a routine to draw the text pixel by pixel. There's no way for windows
to draw the text that I need to draw - the typeface and certain characters
can be modified on the fly.
D.
|
|
| Back to top |
|
 |
Nicholas Sherlock Guest
|
Posted: Wed Jan 11, 2006 3:24 am Post subject: Re: Getting the text under the cursor from any application |
|
|
Paul Dunn wrote:
| Quote: | Nicholas Sherlock wrote:
Paul Dunn wrote:
My own flagship app, BASin (an IDE for a BASIC language, written in
Delphi) doesn't display any system text in the editor - it's *all*
bitmapped. You'd need to get access to BASin's memory to pull the
text out, and even then it's not actually stored as text, but tokens.
So yes, OCR is the *only* way.
For applications like these you could possibly get really creative and
hook TextOut with Madshi.net's MadHook.
Would that actually work?
As I don't call any text routines - I declare a graphical surface and then
write a routine to draw the text pixel by pixel. There's no way for windows
to draw the text that I need to draw - the typeface and certain characters
can be modified on the fly.
|
Ah, yes, it would be impossible to hook this way if you are not using
Windows textout routines. With other applications you could use a
simplified OCR which only looks for exact matches from a set of fonts,
but this would not work for your specific application as you are not
using standard fonts, so you'd have to fall back to a complete and
complex OCR package.
Cheers,
Nicholas Sherlock
|
|
| Back to top |
|
 |
Born Guest
|
Posted: Thu Jan 12, 2006 9:46 am Post subject: Re: Getting the text under the cursor from any application |
|
|
Thanks.
I'm wil look into both optios.
When i meant all applications I didn't mean ALL applications;)
But the OCR bit is interesting aswell
First i will look into getwindowtext
Maybe that will do for the time being.
Best whishes
Ebo Dieben
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|