none
I want to store messages from my webbrowser game on my disk. RRS feed

  • Question

  • Hello everyone 

    I'm kind new to vb and i want to start a project, and i just couldn't find what i am looking for

    What i look for is an application that you set a location , kind of data scrape 

    Read text from cursor location

    i just don't know how to tell exactly

    thanks in advance


    • Edited by Quinthus Tuesday, March 13, 2018 5:33 PM
    Monday, March 12, 2018 10:53 PM

All replies

  • What i look for is an application that you set a location , kind of data scrape 

    Read text from cursor location

    What sort of location?  On the screen, in a text file, on a www page, within an application, or something else?

    Monday, March 12, 2018 11:00 PM
  • On the screen within an application

    or select some kind of form ... something like select an area to read all text from that area , and transcribe it to a label or something

    • Edited by Quinthus Monday, March 12, 2018 11:04 PM
    Monday, March 12, 2018 11:02 PM
  • On the screen within an application

    The screen display is not text - it is an image.  You can grab an image of the screen and attempt to use OCR to convert it to text. That is difficult and may be inaccurate, but it will work for any source. You can see how it would be done here: http://capture2text.sourceforge.net/

    If it's an application then it may be possible to get access to the internals of the application and read text from a control such as a text box or a list. See, for example:
    https://stackoverflow.com/questions/17615105/getting-text-entered-in-textbox-of-other-applications-using-c-sharp

    That code would need to be converted to VB (there are on-line converters available) but it shows you how it is possible to get the application process ID details, and the details of the control within the application, and the text within that control.  The code is very specific to the source.  This is not an exercise for a beginner programmer.

    • Proposed as answer by Cor Ligthert Tuesday, March 13, 2018 12:44 AM
    • Unproposed as answer by Cor Ligthert Tuesday, March 13, 2018 6:14 PM
    Monday, March 12, 2018 11:21 PM
  • and get the text from different application , i want something like capture2text but integrated to my application

    i know that it's possible to do things like that but i don't know how to search for it...

    Tuesday, March 13, 2018 3:39 PM

  • i know that it's possible to do things like that but i don't know how to search for it...

    Yes it is possible. By the way can you fly a Jumbo Jet because that is probably easier and that is also possible. If it was as easy as you describe it, there would not be anymore copy and paste. 

    Be aware we all assume you are not talking about copy and paste or dragging but scraping. 

     

    Success
    Cor



    Tuesday, March 13, 2018 3:48 PM
  • i just want somehow to integrate capture2text to my application...

    i repeat that i don't know how to search it ..

    Tuesday, March 13, 2018 3:58 PM
  • Quintes

    If it is from a screen alone it is no text it are just pixels. Acamar gave you an explanation of that. 

    If it is text in another program which has not made this possible using Interop, then the name for doing it in the way you want has the name hacking. 

    MS Office has for instance many ways for Interop, Notepad has not one. But if you want to do it from another program then you have to use for every text the method supplied with that program. 


    Success
    Cor

    Tuesday, March 13, 2018 4:08 PM
  • Hopefully this picture will clear the language barrier 

    Cor, you did not understand me, it is a webbrowser game, the red highlighted text i want to transcribe to my vb application, hope you'll understand and can help me, thanks

    Tuesday, March 13, 2018 4:52 PM
  • On the screen within an application

    or select some kind of form ... something like select an area to read all text from that area , and transcribe it to a label or something

    You can use Tesseract to perform OCR.

    Tesseract can be installed from NuGet (Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution).

    Then download the language data from:
    https://github.com/tesseract-ocr/tessdata/releases/tag/3.04.00

    Add a folder to your project called "TessData" and then add the language files from the download into this folder and set Copy To Output Directory to Always for each file.  If you only want to support English you can just add the files that being with eng.

    With that done you can now create a bitmap image from the screen or wherever and attempt to OCR it.

    Here's an overly simplified code example:

    Dim ocr As New Tesseract.TesseractEngine("TessData", "eng")
    Using img As New Bitmap(Screen.PrimaryScreen.Bounds.Size.Width, Screen.PrimaryScreen.Bounds.Size.Height)
        Using g = Graphics.FromImage(img)
            g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size)
        End Using
        Dim page = ocr.Process(img)
        RichTextBox1.Text = page.GetText
    End Using
    
    You'll probably want to do a lot more than that to narrow down the part of the image you want to process and/or improve the image quality to increase the OCR accuracy.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, March 13, 2018 4:55 PM
    Moderator
  • thanks for fast reply, i'm trying that out, hope that'll solve my problem :)
    Tuesday, March 13, 2018 4:59 PM
  • If it is a webbrowsergame then you got it in HTML4/5, a script, or an active pluggin. 

    You can see that normally by right clicking on that page and ask to show the page source. 

    Maybe you see that text in that source.  (after right clicking it can be under more) 

    But there are of course more ways, maybe you can trigger mr. Monkeyboy when you create a new question. But than you should make a direct understandable header for your question. 

    Likewise. 

    I want to store messages from my webbrowser game on my disk. 


    Success
    Cor




    Tuesday, March 13, 2018 5:19 PM
  • it is an active plugin, but how can i transcribe that text in real time to my application?

    i don't want to store messages, i want to transcribe them to my app in real-time...

    • Edited by Quinthus Tuesday, March 13, 2018 5:27 PM
    Tuesday, March 13, 2018 5:22 PM
  • Yea that is like I wrote already, then you should invest how that pluggin can give data to you. OCR is always a kind of gamble and only good if you direct see the result when busy. Try what i told and change your question header. There are persons who are good in it and maybe will help you. 

    Be aware your problem is not what you ask currently. 

      If you store them by the way is not important, it is only to get simply communicate what your problem is. Nobody goes telling you in a forum how to write them to disk. 

    Success
    Cor


    Tuesday, March 13, 2018 5:30 PM
  • Yea that is like I wrote already, then you should invest how that pluggin can give data to you. OCR is always a kind of gamble and only good if you direct see the result when busy. Try what i told and change your question header. There are persons who are good in it and maybe will help you. 

    Be aware your problem is not what you ask currently. 

      If you store them by the way is not important, it is only to get simply communicate what your problem is. Nobody goes telling you in a forum how to write them to disk. 

    Success
    Cor


    done, title modified, thx in advance, hope it will help me someone
    Tuesday, March 13, 2018 5:36 PM
  • done, title modified, thx in advance, hope it will help me someone
    Then use the first case that I mentioned in the post above - screen capture combined with OCR.   That text appears to be suitable. The only problem you might have is getting the selected screen area to follow the text portion of the game display - that might have to be done manually.  
    Tuesday, March 13, 2018 9:45 PM
  • i just want somehow to integrate capture2text to my application...

    i repeat that i don't know how to search it ..

    If you have two applications and both are written by you then you can get text from one to the other using Interprocess Communications as the simplest method.

    Another method which will work between your application and another application that is not yours, such as Notepad, would require the use of Pinvoke(s) to use appropriate C++ or native .Dll's that will perform the work. And then you have to know which window in another app to get the text from. It would need to be a window that contains text and not an image for example.

    I believe Cor already mentioned the use of OCR for screen scraping words from an image. This requires the use of libraries that can find words in an image.

    A WebBrowsers webpage is an entirely different matter. Its source code typically contains HTML and maybe CSS and Java Script and possibly more. That source tells the WebBrowser what to display, how and where to display it. It's possible the source may contain the text you want but it's possible the source has a link for where to get the text that is to be displayed.

    You are knew to VB but attempting to ask advanced abilities beyond simple although maybe they can be performed by you or not without somebody else providing lengthy explanations and making sure you do things correctly. With little to no experience in VB you will take on a difficult challenger for a 1st timer which is O.K. However just because you want to do something does not mean the task is beginner level.

    Therefore when you ask a question by all means be explicit on what exactly you want your program to perform. I.E. "I have a link to a WebSites webpage and was wondering if I could extract text displayed in the webpage possibly?" or something intricate explaining such that others realize you aren't wanting to extract text from an external applications text window. It will make things much easier for anybody attempting to assist you.

    I suspect you may be able to use Microsoft.mshtml to extract that text but without a link to the webpage it can not be tested by me.


    La vida loca

    Wednesday, March 14, 2018 12:21 AM
  • the game is triviador, i want to extract the questions from the game in real-time

    Wednesday, March 14, 2018 11:13 AM
  • Why don't you try to contact the makers of Triviador. I see it is a Google game and especially that company has done a lot for making their programs interoperable. 

    I expected already that you wanted to do it in real time, therefore OCR is probably a bad solution in this case. 


    Success
    Cor



    Wednesday, March 14, 2018 12:01 PM