Solved

How to capture the word displayed on screen?

Posted on 1998-09-27
11
222 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

19 Experts available now in Live!

Get 1:1 Help Now