Eli, onko VB6 mahdollista toteuttaa seuraavanlaista suunnitelmaa:
Jos ruudulla on jokin tietty väri, esim musta (tai &H000000), hiiri menee automaattisesti mustan kohdan päälle ja klikka sitä?
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Sub Command1_Click() Dim x As Single, y As Single 'tahdotaan muuttujeit For x = 0 To Picture1.ScaleWidth 'käydään loota läpi forrilla For y = 0 To Picture1.ScaleHeight If GetPixel(Picture1.hdc, x, y) = 0 Then 'jos tässä kohti akkunaa on musta pikseli Picture1_MouseDown 0, 0, x, y 'kutsutaan aliohjelmaa End If Next y Next x End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) MsgBox x & "," & y End End Sub
Onko tuosta apua?
Muuten hyvä, mutta tuo musta alue voi olla missä tahansa ikkunassa. Jos saisi sellaista joka etsii kaiken mustan, ja ensimmäinen musta kohta joka tulee vastaan, klikataan siitä.
Tekeekö tämä koodi suunnilleen haluamasi?
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long 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 MOUSEEVENTF_LEFTDOWN = &H2 Private Const MOUSEEVENTF_LEFTUP = &H4
Dim x As Long, y As Long Dim l As Long, k As Long Dim v As Long Dim n As Long n = GetDC(0) v = RGB(0, 0, 0) l = Screen.Width / Screen.TwipsPerPixelX k = Screen.Height / Screen.TwipsPerPixelY For y = 0 To k For x = 0 To l If GetPixel(n, x, y) = v Then SetCursorPos x, y mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 End End If Next Next
Aihe on jo aika vanha, joten et voi enää vastata siihen.