|
-
Apr 25th, 2013, 03:59 PM
#1
Thread Starter
Member
[SOLVED] Conditional with Pixel Color?
Hello 
I would make this:
Code:
If (Coords) = FFF0F0F0 Then
.......
Else
.....
End If
But i don't have any idea about how can i make this.
Thanks and sorry my enlgish errors.
Last edited by pguti19; Apr 26th, 2013 at 01:25 PM.
-
Apr 25th, 2013, 04:25 PM
#2
Re: Conditional with Pixel Color?
Create a bitmap that represents your screen, then use Bitmap.GetPixel to get the color of a specific coordinate. To check if the color matches your html color code, use ColorTranslator.FromHtml.
-
Apr 25th, 2013, 04:29 PM
#3
Re: Conditional with Pixel Color?
You must commit whatever you're scanning to a Bitmap first (if it's a form background image or similar then you already have that step done).
If bmp.GetPixel(x, y) = Color.FromArgb(&HFF, &HF0, &HF0, &HF0) Then
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 25th, 2013, 04:34 PM
#4
Thread Starter
Member
Re: Conditional with Pixel Color?
I have a bad - medium level in VB and i don't know how to manage Libs. I need some libs?
The color is in a Windows (Chrome).
How can i scan it?
Thanks a lot
-
Apr 25th, 2013, 04:52 PM
#5
Re: Conditional with Pixel Color?
 Originally Posted by pguti19
How can i scan it?
Refer to post #2.
-
Apr 25th, 2013, 04:58 PM
#6
Thread Starter
Member
Re: Conditional with Pixel Color?
I think that i didn't say good.
I select a coords (X=100 Y=900 for example) and If this point is color #FF43523 Then...
Bitmap.GetPixel scan all scren, or a image.
It's the same for my question?
-
Apr 25th, 2013, 05:04 PM
#7
Re: Conditional with Pixel Color?
Did you read the documentation on Bitmap.GetPixel?
Gets the color of the specified pixel in this Bitmap.
That's why in post #2 I suggest to create a bitmap that represents your form, then use Bitmap.GetPixel to get a color of the specified pixel.
-
Apr 25th, 2013, 05:27 PM
#8
Thread Starter
Member
Re: Conditional with Pixel Color?
Sorry if i'm saying nonsenses, but i never manage this topic.
With Bitmap.GetPixel I need say one file:
Dim myBitmap As New Bitmap("grapes.jpg")
Dim pixelColor As Color = myBitmap.GetPixel(50, 50)
I need that the bold text will be my screen. How can i make this?
-
Apr 25th, 2013, 06:03 PM
#9
Thread Starter
Member
Re: Conditional with Pixel Color?
I have this code:
Dim myBitmap As New Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
Dim something As Color = myBitmap.GetPixel(50, 50)
Dim something1 As Color = TextBox3.BackColor
If something = TextBox3.BackColor Then
TextBox3.Text = ":-D"
Else
TextBox3.Text = "D-:"
End If
But how can I tell VB the coords that I want get pixel?
-
Apr 25th, 2013, 08:04 PM
#10
Re: Conditional with Pixel Color?
Dim something As Color = myBitmap.GetPixel(50, 50)
There's the co-ordinates x,y. You change them as you wish.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 25th, 2013, 11:24 PM
#11
Re: Conditional with Pixel Color?
I...think he wants a screenshot to be the bitmap?
-
Apr 26th, 2013, 06:40 AM
#12
Thread Starter
Member
Re: Conditional with Pixel Color?
I want that get pixel of the actual screen; in a started timer.
Don't detect a pixel with ..GetPixel(1014, 615) and is the same color.
-
Apr 26th, 2013, 10:53 AM
#13
Thread Starter
Member
Re: Conditional with Pixel Color?
I only need to do that in coord (1000, 500) if is #FF09532 do something, and else, another thing.
Code:
If coord (1000, 500) = #FF09532 Then
Textbox1.text = "Hello"
Else
Textbox1.text = "Bye"
End If
For example.
Last edited by pguti19; Apr 26th, 2013 at 10:58 AM.
-
Apr 26th, 2013, 11:08 AM
#14
Re: Conditional with Pixel Color?
 Originally Posted by pguti19
I only need to do that in coord (1000, 500) if is #FF09532 do something, and else, another thing.
Of the form or the whole screen?
-
Apr 26th, 2013, 11:19 AM
#15
Thread Starter
Member
Re: Conditional with Pixel Color?
Is one windows of Google Chrome where i want scan.
The scan is enabled by other conditional.
Code:
If textbox2.text = "0" Then
If coord (1000, 500) = #FF09532 Then
Timer3.start()
Else
Timer2.stop()
Timer1.stop()
End If
End If
One example.
-
Apr 26th, 2013, 01:07 PM
#16
Thread Starter
Member
Re: Conditional with Pixel Color?
Okey, now i can make this Conditional, but i need how to equate this:
Code:
Dim myBmp As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
If Label1.BackColor = mybmp.GetPixel(TextBox1.Text, TextBox2.Text) Then
label2.text = "YEAH"
Else
label2.text = "D:"
End If
Because If i put the same color, Label2.text is "D:" and have to write "YEAH"...
-
Apr 26th, 2013, 01:25 PM
#17
Thread Starter
Member
Re: Conditional with Pixel Color?
Sorry for triple post.
SOLVED:
Code:
Public Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As Integer
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
____________________________________________________________________________________________________________________
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim myBmp As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Dim g As Graphics = Graphics.FromImage(myBmp)
g.CopyFromScreen(Point.Empty, Point.Empty, myBmp.Size)
g.Dispose()
Label2.BackColor = myBmp.GetPixel(TextBox1.Text, TextBox2.Text)
myBmp.Dispose()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Timer2.Start()
End Sub
Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
Dim myBmp As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
If Label2.BackColor = Label1.BackColor Then
Label2.Text = "YEAH"
Timer2.Stop()
Else
Label2.Text = "D:"
Timer2.Stop()
End If
End Sub
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
|