|
分類:[VB.NET/VB2005 以降]
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim screensize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenshot As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenshot)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screensize)
Dim pointx As Integer = 30
Dim pointy As Integer = 30
Dim looking As Boolean = True
While looking = True
Dim atpoint As Color = screenshot.GetPixel(pointx, pointy)
Dim White As Color = Color.FromArgb(255, 220, 55, 97)
If atpoint = White Then
Cursor.Position = New Point(pointx, pointy)
mouse_event(mousdown, 0, 0, 0, 0) 'マウスダウン
mouse_event(mousup, 0, 0, 0, 0) 'マウスアップ
looking = False
pointx = 1
pointy = 1
End If
pointy = pointy + 1
If pointy = My.Computer.Screen.Bounds.Height Then
pointy = 0
pointx = pointx + 1
End If
End While
End Sub
'API関数の宣言部分
<System.Runtime.InteropServices.DllImport("USER32.DLL")> _
Private Shared Sub mouse_event(ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
End Sub
'定数宣言
Private Const mousup As Integer = &H4 '左ボタンUP
Private Const mousdown As Integer = &H2 '左ボタンDown
End Class
うえの色判定でクリックスル処理を無限ループさせたいのですが。。
do loopだと固まってしまいました
|