Solved

How to capture the word displayed on screen?

Posted on 1998-09-27
11
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 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