Solved

How to capture the word displayed on screen?

Posted on 1998-09-27
11
225 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
ID: 1340951
That is a deffecult task..

Motaz
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1340952
That is a deffecult task..

Motaz
0
 

Author Comment

by:yc
ID: 1340953
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 7

Expert Comment

by:Motaz
ID: 1340954
What did you want to do exactly yc ?

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

Motaz
0
 

Author Comment

by:yc
ID: 1340955
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
 

Author Comment

by:yc
ID: 1340956
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
ID: 1340957
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
ID: 1340958
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
ID: 1340959
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
ID: 1340960
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
ID: 1340961
Adjusted points to 55
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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