|
-
Jun 7th, 2013, 01:19 AM
#1
Thread Starter
Frenzied Member
question: copy from and paste to original form
Good day. I have this form on Application A and it has picturebox and a textbox.
Now I have another form on Application A which purpose is to read the picturebox texts and post it back to textbox on Form on application A.
Guys I have no idea on this but I hope someone can give me assistance on how to resolve this.
-
Jun 7th, 2013, 06:24 AM
#2
Re: question: copy from and paste to original form
Just so I understand.....you have, on one form, a picturebox and a textbox. And on the second form, you probably have a commandbutton in whose click event you want to 'read' what is in the picturebox on form1 and paste the 'text' into the textbox on form1.
If so, a couple of questions. Why a second form, why not just a command button on the first form?
WHAT is in the picturebox? Is it an 'image' of some text?
-
Jun 7th, 2013, 06:51 AM
#3
Re: question: copy from and paste to original form
If you use something like this to put text into your picturebox on form1, you can simply make the string variable global (in a module) and display it on form1 from form2. BUT, again, why use two forms?
Code:
Option Explicit
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Const DT_CENTER = &H1
Const DT_WORDBREAK = &H10
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim rc As RECT, strText As String
strText = "The quick brown fox jumps over the lazy dog."
With Picture1
.AutoRedraw = True
.ScaleMode = vbPixels '3
rc.Right = .ScaleWidth
rc.Bottom = .ScaleHeight
DrawText .hdc, strText, -1, rc, DT_WORDBREAK 'Or DT_CENTER
End With
End Sub
In the above example, if you want to 'read' the text in the picturebox, simply do: text1.text = strText.
-
Jun 7th, 2013, 07:57 AM
#4
Re: question: copy from and paste to original form
Something tells me there's more to it... I think I know what's going on... but I want to hear more from the OP before deciding what to do or how to respond directly. I've seen these kinds of questions before.
@codesearcher - not sure why you have two forms, but you'll might want to explain a little more about what it is you're trying to accomplish. Is the text you're trying to read part of the image that's in the picture box? Or is it the .Text property of the picturebox (which I'm not sure it has), is it text written to the picturebox using a technique like Sam showed? your description is vague and lacking certain details. Often the solution varies depending on the details of the situation. Sometimes people try to simplify the question and in the process get answers that end up not working because details were left out.
-tg
-
Jun 7th, 2013, 08:10 AM
#5
Thread Starter
Frenzied Member
Re: question: copy from and paste to original form
its a transcription work. and I got this separate program that shows the document on jpg format but I need to convert that to text using OCR or something and paste it back to the textbox. I am thinking if is it possible with my separate program to get that document on jpg format and convert that to text and paste to its textbox.
-
Jun 7th, 2013, 08:29 AM
#6
Re: question: copy from and paste to original form
now I am glad I kept mums... because that's NOT what I thought was going on... so the bottom line is that you want to write your own OCR application... It's not something I know how to do, not some think I care to know how to do... but I do know it isn't easy or all that simple. Basically you're taking an image and scanning it's pixels for patterns and then attempting to recognize those patterns into text.
-tg
-
Jun 7th, 2013, 08:56 AM
#7
Thread Starter
Frenzied Member
Re: question: copy from and paste to original form
techgnome, yes not just only an ocr but to scan an picturebox from another application and programmatically post the scanned text to the texbox of that application.
-
Jun 7th, 2013, 09:01 AM
#8
Re: question: copy from and paste to original form
Nor I......is this for reading CAPTCHA images? If so, doesn't belong on this forum.
-
Jun 7th, 2013, 09:14 AM
#9
Re: question: copy from and paste to original form
 Originally Posted by SamOscarBrown
Nor I......is this for reading CAPTCHA images? If so, doesn't belong on this forum.
Did you miss post #5? That's what my original gut instinct was... not the case here though...
 Originally Posted by codesearcher
techgnome, yes not just only an ocr but to scan an picturebox from another application and programmatically post the scanned text to the texbox of that application.
That's what an OCR app does... it scans an image and translates it into a text document of some kind...
And see? you simplified your question and left out the all important detail that the picture box and text box ARE IN A DIFFERENT APP... so that explains why the second form with a button.
Personally I think it's more effort than it's worth, but it could also be because I'm not sure where to start on something like that... dealing with images is not my thing.
-tg
-
Jun 8th, 2013, 09:53 AM
#10
Thread Starter
Frenzied Member
Re: question: copy from and paste to original form
ok I will not ask about coding for OCR.
I would like to achieve now is how to post a record from my application textbox to another applicatio's textbox and send key ENTER on that textbox.
Please kindly assist.
-
Jun 9th, 2013, 11:57 AM
#11
Re: question: copy from and paste to original form
There is a free OCR that works. I tried it the results were "readable" but you would need to loop through words (from dictionary) to fix some mistakes.
Try this free OCR from google, tesseract-ocr-setup-3.02.02.exe
Here is the maine page
https://code.google.com/p/tesseract-ocr/
Go to the ReadMe and it tells you how to use it (using command prompt) can be easy to execute a command prompt command from VB6.
Running Tesseract
Tesseract is a command-line program, so first open a terminal or command prompt. The command is used like this:
tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]
So basic usage to do OCR on an image called 'myscan.png' and save the result to 'out.txt' would be:
tesseract myscan.png out
Or to do the same with German:
tesseract myscan.png out -l deu
It is a start I would think, instead of writing your own which requires you to learn picture files data (header/data). You also need to know matrix matching algorithm, optical letter comparing, and much more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|