Originally Posted by
J-Deezy
Sorry about the slow reply, I forgot about it xD
Anyways here's my code for triggering a click when mouse is over a certain color.
[REQUIREMENTS]
A timer with an interval of 1. That's it.
[php]
Option Explicit On
Imports System.Runtime.InteropServices
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, ByVal dwExtraInfo As Long)
Private Const LEFTMOUSEUP = &H4
Private Const LEFTMOUSEDOWN = &H2
Private Sub MouseClicks()
mouse_event(LEFTMOUSEDOWN, 0, 0, 0, 0)
mouse_event(LEFTMOUSEUP, 0, 0, 0, 0)
End Sub
<StructLayout(LayoutKind.Sequential)> Private Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
Dim structCursorPosition As POINTAPI
Call GetCursorPos(structCursorPosition)
Dim lColor As Integer = GetPixel(GetDC(0), structCursorPosition.x, structCursorPosition.y)
Dim c As Color = ColorTranslator.FromOle(lColor)
Dim R1, G1, B1 As Integer
R1 = c.R
G1 = c.G
B1 = c.B
If RGB(c.R, c.G, c.B) = RGB(255, 3, 3) Then ' Change the 'RGB(255, 3, 3)' to whatever color'
Call MouseClicks()
MsgBox("OMG IT WORKED") ' remove this, i was just testing'
End If
End Sub
End Class
[/php]
Hope that works for you.