OK, I've finished my project, and it works. But... It makes me lag because I used
Timers. I'd like if you could suggest me where can I render my code simplier!
-What's the program's point?
1) I check a line on my screen with GETCOLOR: from (590,580) to (620,580), with Step "2". So it checks 15 different coordinates.
2) If it finds one of 3 colors on this coordinates, then LefClickDown activates.
The problem is that I've used a Timer with Interval "1"... (1000 = 1 second) so it's quite fast and in this way it produces frame lag!
Now I'll post a peace of code so you can see it and laugh on it:
peace of code from "Base" named form:
__________________________________________________
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Start" Then
Button1.Text = "Stop"
Cross.Timer2.Start()
Else
Button1.Text = "Start"
Cross.Timer2.Stop()
Cross.Timer3.Stop()
End If
____________________________________________
peace of code from "Cross" named form:
____________________________________________
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
' In declare module, Public x As Integer = 590
If x = 620 Then
Timer2.Stop() 'the current one
Timer3.Start() 'the one under this one
Else
'x is variable... 15 times as I told before. Y is static.
MyColor = GetScreenPixel(New Point(x, 580))
htmlColor = ColorTranslator.ToHtml(MyColor)
'this are 3 colors I'm looking for in this interval of 15 coordinates
If htmlColor = "#FF2222" Or htmlColor = "F08B6B" Or htmlColor = "ED3931" Then
'there is an Event Sub, which presses mouse left button, but doesn't release it (Only MouseDown)
PerformMouseClick("LClick")
End If
x = x + 2
End If
End Sub
'This timer is inverted... it goes from x: 620 to x:590.... so my search style is like this: 1) ->>>>>> 2) <<<<<<- ... It goes and returns all the time.
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If x = 590 Then
Timer3.Stop()
Timer2.Start()
Else
MyColor = GetScreenPixel(New Point(x, 580))
htmlColor = ColorTranslator.ToHtml(MyColor)
If htmlColor = "#FF2222" Or htmlColor = "F08B6B" Or htmlColor = "ED3931" Then
PerformMouseClick("LClick")
End If
x = x - 2
End If
End Sub
NOW..... I need to know if I could remove timers and put
everything on MouseHover Event (Hover searched Pixel Color). So when I move the mouse in every point of the screen, it makes this search.... And if it detects one of 3 colors, when the pointed Pixel is the one I'm searching for, then the LEFT MOUSE DOWN activates..... WHILE, when MouseLeave() [the searched pixel is no more pointed by the cursor, then LEFT MOUSE UP activates.
The problem is that MouseHover works only for the FORM... hover the form, and not hover the searching point which is out of the form..