Question How to screen detection?

timiimit

Member
Joined
Feb 13, 2012
Messages
6
Programming Experience
Beginner
Hello!
I am making a program and I need to know how to detect if certain image on screen.
I have saved some picture and if it see's it on screen i want to do something like make msgbox.
 
Okay I tried something and it works but I'm not quite sure its exactly what you want. And I doubt you actually detect whether a certain image shown in the screen.

Anyway, here's what I tried.

I just created a simple interface with a Button and a Picturebox. An I also added a OpenFileDialog control to the form.

In the Click event of the Button it pops up the OpenFileDialog for the user to select an image from the computers HD. Below is the code.

Public Class Form1


    Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click


        'stores the filename withthe path 
        Dim fileName As String


        'sets the OpenFileDialog's path to Pictures folder
        OpenFileDialog1.InitialDirectory = "Libraries\Pictures"
        OpenFileDialog1.ShowDialog()


        'gets the filename to the previously declared variable
        fileName = OpenFileDialog1.FileName
        TextBox1.Text = fileName


        'loads the picture to the Picturebox
        PictureBox1.Image = Image.FromFile(fileName)


        'if the filename matches the filepath stored in teh program, it shows the messagebox
        If fileName = "C:\Users\nK0de\Pictures\tumblr_luwduahtnt1qzdsqh.png" Then
            MessageBox.Show("Hey, its that red haired girl's pic!")
        End If


        OpenFileDialog1.Reset()


    End Sub


End Class


Here's the output.

red hair pic.png

Since that filepath is stored in the program, the messagebox pops up. If its not stored, the messagebox won't show up. So you'll have to store the paths of all the images to check which one is showing in the Picturebox. You can use an ArrayList (ArrayList Class (System.Collections)) or a Generic List (List(T) Class (System.Collections.Generic)) to store them and use a Loop to check against whether they exist.
 
No. For eg. I have google picture saved and when i open google.com it does something, like msgbox.
But not to detect that is in picturebox.
only if it's on screen (not specified position OR certain picturebox).
 
I don't think you can do that. (or maybe I'm just wrong. wait until someone who's done something similar sees your question then)
 
Can mabye this help:

Dim BMP As New Drawing.Bitmap(1, 1)
Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
New Drawing.Point(0, 0), BMP.Size)
Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
Me.BackColor = Pixel


I've got it from youtube!
tomake
To make It work u need timer.
But instead of getting color i have to get image( i know this is not thesame. I'm not noob!!).
 
Last edited:
Back
Top