Anmeldungsdatum: Mai 2008
Beiträge: 8
|
ich habe mir das jetzt so überlegt, aber es funktioniert wieder nicht
TEXT Code: Imports System.Runtime.InteropServices Public Class Form1 Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As UShort Public pixColor As Color = GetPixelColor(Cursor.Position.X, Cursor.Position.Y) Public modelcolor As Color = GetPixelColor(Cursor.Position.X, Cursor.Position.Y) Public ForeColorStr As String Public model As String <DllImport("gdi32.dll")> _ Private Shared Function CreateDC( _ ByVal lpszDriver As String, _ ByVal lpszDevice As String, _ ByVal lpszOutput As String, _ ByVal lpInitData As IntPtr) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function DeleteDC(ByVal hdc As IntPtr) As Boolean End Function <DllImport("gdi32.dll")> _ Private Shared Function GetPixel( _ ByVal hdc As IntPtr, _ ByVal nXPos As Integer, _ ByVal nYPos As Integer) As Integer End Function Public Function GetPixelColor(ByVal x As Integer, ByVal y As Integer) As Color Dim hdcScreen As IntPtr = CreateDC("Display", Nothing, Nothing, IntPtr.Zero) Dim colorRef As Integer = GetPixel(hdcScreen, x, y) DeleteDC(hdcScreen) Return Color.FromArgb(colorRef And &HFF, _ (colorRef And &HFF00) >> 8, (colorRef And &HFF0000) >> 16) End Function Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Public Const MOUSEEVENTF_LEFTDOWN = &H2 Public Const MOUSEEVENTF_LEFTUP = &H4 Public Sub SimulateClick() mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If CBool(GetAsyncKeyState(Keys.F12)) Then Dim pixColor As Color = GetPixelColor(Cursor.Position.X, Cursor.Position.Y) Dim ForeColorStr As String = ColorTranslator.ToHtml(pixColor) Label1.Text = ForeColorStr Timer3.Enabled = True Timer1.Enabled = False End If End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick Do Until model <> ForeColorStr Dim modelcolor As Color = GetPixelColor(Cursor.Position.X, Cursor.Position.Y) Dim model As String = ColorTranslator.ToHtml(modelcolor) Label2.Text = model Loop SimulateClick() End Sub End Class
|