We help IT Professionals succeed at work.

VB6 and Snagit.. (Text capture from Web Page Image)

turnerrob
turnerrob asked
on
Has anyone had any experience with a program called Snagit, using VB6.

I need to capture text from a web page, into a VB6 program.
The web page section i need to capture is an image containing text.

Snagit allows selction of a window via a handle, and then it OCR's the area, and places the text into a file or clipboard.

I am having problems with the operation
eg  .linkexecute  etc.

======
or.
Is there another way of doing this.

I will be more positive with the detail, if anyone is able to offer advice.!!

Appreciate any help
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Hi

'========bas module code========
Option Explicit

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function ChangeClipboardChain Lib "user32" (ByVal hwnd As Long, ByVal hWndNext As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const WM_DESTROY = &H2
Public Const WM_DRAWCLIPBOARD = &H308
Public Const WM_CHANGECBCHAIN = &H30D
Public Const GWL_WNDPROC = (-4)

Public OldProc As Long, CBChain As Long

Public Function WndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Dim sText As String
    Select Case wMsg
        Case WM_DRAWCLIPBOARD
            sText = "Clipboard clear"
            If Clipboard.GetFormat(vbCFText) Then
               sText = "Text added!"
               Form1.Text1.Text = Clipboard.GetText
            End If
            If Clipboard.GetFormat(vbCFBitmap) Then
               sText = "Picture added!"
               Form1.Picture1.Picture = Clipboard.GetData(vbCFBitmap)
            End If
            MsgBox sText
            SendMessage CBChain, wMsg, wParam, ByVal lParam
    End Select
    WndProc = CallWindowProc(OldProc, hwnd, wMsg, wParam, lParam)
End Function

'======Form code========
'Add multiline textbox and picturebox to form
Private Sub Form_Load()
    Clipboard.Clear
    OldProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc)
    CBChain = SetClipboardViewer(hwnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ChangeClipboardChain hwnd, CBChain
    SetWindowLong hwnd, GWL_WNDPROC, OldProc
End Sub

Cheers

Author

Commented:
Ark.
Thanks for your reply.
I have tried the code, and it does very neatly transfer the clipboard to a text box.
This will help me in Stage 2 of my project.

The main problem i have is...
I have a web page displayed.
A section of the web page contains text which i need to extract., the problem is,, the text is contained in an image on the page.
ie. if i find the handle of the area on the web page, there is no text at the handle.
I need to capture the area of the screen, OCR it, and extract the text.

***********
I can not see any way of doing this in VB.
***********  If there is a simple way , i would appreciate some advice.


I have purchased Snagit, which does OCR an image area of a web page, and return the text., but i am having trouble getting it to work completely.

Hope this clarify's my problem.

Regards

Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT

Commented:
<learning..>
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
learning too :)
Ark
CERTIFIED EXPERT

Commented:
In this case why not simply get HTMLDocument from this page and parse tags to get text?

Cheers

Author

Commented:
ark...
parse tags ?????
I do not understand this command.


If i save the html page there is next to nothing in it.
It refers to a plugin program, which displays the data.
ie.  The data i am after is not in html format.
I need to capture the image and ocr it.

Regards  turnerrob
Ark
CERTIFIED EXPERT

Commented:
Oh, I see... I thought you have html page with some background picture and text on it....
In your case you can start SnagIt when your app starts (with predefined settings In - ActiveForm, Out - ClipBoard) and when nesessarry, use keybd_event API to press hot key combination.

Cheers

Author

Commented:
I have actually got Snagit Running ok.
The problem i had was the command lines needed double (") quotes in the line.
I created
Q=Chr(34)
and used this in the line instead of "
I should have worked it out early in the eposide!!!

Snagit works well and does the job automatically, the only problem is, the whole area i am trying to capture must be fully visible on the screen to get the image.

Thanks Ark for your comments, and the help with transferring the clipboard to a text box.