Results 1 to 3 of 3

Thread: Grabbing part of the screen.......

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    Lancashire, England
    Posts
    4

    Grabbing part of the screen.......

    Dear All, I would like to grab a section of the screen containing some numbers and then perform OCR on the resultant image. I think I've got the recognition sorted and I have an idea about how to get the area of the screen that I am interested in. I just don't know how to put it into a file. Any help???

    Thanks in advance.

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    start a new project and add a commandbutton and a picturebox
    then add this code to the form:

    VB Code:
    1. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    2. Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
    3. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    4. Dim DC As Long
    5. Dim iWidth As Single
    6. Dim iHeight As Single
    7. Dim iFromX As Single
    8. Dim iFromY As Single
    9.  
    10. Private Sub Command1_Click()
    11.     iWidth = Picture1.ScaleWidth
    12.     iHeight = Picture1.ScaleHeight
    13.     iFromX = 200
    14.     iFromY = 200
    15.    
    16.     DC = GetWindowDC(GetDesktopWindow)
    17.     BitBlt Picture1.hDC, 0, 0, iWidth, iHeight, DC, iFromX, iFromY, vbSrcCopy
    18.     Picture1.Refresh
    19. End Sub
    20.  
    21. Private Sub Form_Load()
    22.     Picture1.ScaleMode = 3
    23.     Picture1.AutoRedraw = True
    24. End Sub
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    Lancashire, England
    Posts
    4

    Thumbs up Thanks!

    Thanks for the help. Let's see how I get on now.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width