Solved

How to capture the word displayed on screen?

Posted on 1998-09-27
11
220 Views
Last Modified: 2010-08-05
I want my application can capture the word displayed on the screen.

I know if the word is in picture, i could not capture it.

But if it is displayed through fonts files, how can i capture it after the mouse pointer stay on it a second?
0
Comment
Question by:yc
  • 6
  • 3
  • 2
11 Comments
 
LVL 7

Expert Comment

by:Motaz
Comment Utility
That is a deffecult task..

Motaz
0
 
LVL 7

Expert Comment

by:Motaz
Comment Utility
That is a deffecult task..

Motaz
0
 

Author Comment

by:yc
Comment Utility
Hi, Motaz

Just as you said! I think the question is very difficult.

I will add the point for it every day! :)

I think i can do some translating between two language through the function.


Regards

Ye Chen
0
 
LVL 7

Expert Comment

by:Motaz
Comment Utility
What did you want to do exactly yc ?

Why did you want to capture text in a bitmap ??

Motaz
0
 

Author Comment

by:yc
Comment Utility
Hi, Motaz

I do not want to capture the words in a image.

I only want to capture the word print to screen.

The following is my thinking:

1.) Modify the displaying function in API such as TextOut...
When the mouse position is in the area of which the word's position printing to screen, transmit the word to my application.

1.) Set a timer:
It will active a second or less than a second.
when it works, it can recording the mouse postion and compare with the last time. If the position is same than do 2.)

2.) Force to refresh the displaying the mouse position. The result is 0.) will capture the word on mouse position.

How do you think?

Regards

Ye Chen




0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:yc
Comment Utility
Hi, Motaz

I do not want to capture the words in a image.

I only want to capture the word print to screen.

The following is my thinking:

1.) Modify the displaying function in API such as TextOut...
When the mouse position is in the area of which the word's position printing to screen, transmit the word to my application.

1.) Set a timer:
It will active a second or less than a second.
when it works, it can recording the mouse postion and compare with the last time. If the position is same than do 2.)

2.) Force to refresh the displaying the mouse position. The result is 0.) will capture the word on mouse position.

How do you think?

Regards

Ye Chen




0
 

Accepted Solution

by:
belgianbasman earned 50 total points
Comment Utility
Hello Ye Chen,

I think that, once you output a string to a canvas with textout, it becomes part of a picture, and you can't retrieve it any longer.  There is a solution to your problem, though....

What you could do is store all strings you output to the canvas with an array, a linked list of records or a database.  Then in the onMouseOver event of the component that is the owner of the canvas, do ...

suppose for argument's sake that you opt for a linked list of records. In the TYPE-section of your .pas file enter ...

DrawnTextPointer = ^DrawnText;
DrawnText  = Record;
   top : Integer;
   left : Integer;
   text : String;
   Next : DrawnTextPointer
END;

in the VAR-section enter :

CurrentDrawnText, FirstDrawnText : DrawnTextPointer;

Now, in an initializing section, set FirstDrawnText to nil.
Then, whenever a text is drawn to the canvas do this ...

CurrentDrawnText:=new(DrawnText);
if FirstDrawnText=nil then
  begin
      FirstDrawnText:=CurrentDrawnText
  end
else
  begin
      CurrentDrawnText^.Next:=FirstDrawnText;
      FirstDrawnText:=CurrentDrawnText;
  end;
CurrentDrawnText^.Next:=nil;
CurrentDrawnText^.Top:=  <top value of the point where the string has to be drawn>
CurrentDrawnText^.Left:=  <left value of the point where the string has to be drawn>
CurrentDrawnText^.Text:=  <the string that has to be drawn>
.. <draw the string to the canvas the way you are used to, with TextOut>

then in the OnMouseOver enter :

currentDrawnText:=FirstDrawnText;
while not CurrentDrawnText=nil do
   begin
          if ((X>CurrentDrawnText^.Left) AND (X<(CurrentDrawnText.Left + Canvas.TextWidth(CurrentDrawnText^.Text))) AND (Y>CurrentDrawnText^.Top) AND (Y<CurrentDrawnText^.Top + Canvas.TextHeight('A'))) then
     begin
               do whatever you need to do when the mouse goes over a text
               break;  {will jump out of the loop for efficiency}
     end;
     CurrentDrawnText:=CurrentDrawnText^.Next;
   end;

This is what happens:  for every record, you will check the following condition :
"Is the current X position of the mouse greater than the left value of this text, and smaller that the left value of this text plus its width, and is the current Y position of the mouse greater than the top value of this text, and smaller than the top value of this text plus its height?"  This means "Is the mouse currently over the text in this record?"
if the answer is yes, the if-statement returns TRUE, and then you can do whatever it is you want to do in such a case.

I hope this works, I typed it from memory.  

Good luck !!

Basman
0
 

Author Comment

by:yc
Comment Utility
Hi, belgianbasman

Thanks your helping.

But how can replace the API's text output function.
Now i known TEXTOUT is function need to replace, i wand to know
if there is other function need to modify?

Regards
Ye Chen
0
 

Expert Comment

by:belgianbasman
Comment Utility
You don't have to replace TextOut, just do some other stuff around the calling of TextOut, like the record keeping.

I'll paste in a fragment of the code from my proposed answer, and indicate the line you have to replace with a textout with ##**

CurrentDrawnText:=new(DrawnText);
if FirstDrawnText=nil then
  begin
      FirstDrawnText:=CurrentDrawnText
  end
else
  begin
      CurrentDrawnText^.Next:=FirstDrawnText;
      FirstDrawnText:=CurrentDrawnText;
  end;
CurrentDrawnText^.Next:=nil;
CurrentDrawnText^.Top:=  <top value of the point where the string has to be drawn>
CurrentDrawnText^.Left:=  <left value of the point where the string has to be drawn>
CurrentDrawnText^.Text:=  <the string that has to be drawn>
##** .. <draw the string to the canvas the way you are used to, with TextOut>  ##**

That should do the trick.

0
 

Author Comment

by:yc
Comment Utility
Hi, belgianbasman

Does your code can capture the text printing to screen by other application?

I want capture the word not only print by my program, but also by the other application and the 95/98/nt system.

Regards

Ye Chen
0
 

Author Comment

by:yc
Comment Utility
Adjusted points to 55
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now