legendart / test

강의 준비 테스트
0 stars 0 forks source link

vb code #1

Open legendart opened 1 year ago

legendart commented 1 year ago

Do Dim rect As Rectangle = New Rectangle(100, 100, 100, 100) ' 확인할 영역 좌표 설정 Dim bmp As Bitmap = New Bitmap(rect.Width, rect.Height) Dim gfx As Graphics = Graphics.FromImage(bmp) gfx.CopyFromScreen(rect.Location, Point.Empty, rect.Size) Dim isSame As Boolean = True For y As Integer = 0 To rect.Height - 1 For x As Integer = 0 To rect.Width - 1 If Not bmp.GetPixel(x, y).Equals(Color.White) Then ' 변화가 발생한 경우 isSame = False Exit For End If Next If Not isSame Then Exit For End If Next If isSame Then ' 특정 영역에 변화가 없는 경우 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) ' 마우스 왼쪽 버튼 누르기 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) ' 마우스 왼쪽 버튼 떼기 End If Threading.Thread.Sleep(500) ' 0.5초 대기 Loop

legendart commented 1 year ago

while (true) { Rectangle rect = new Rectangle(100, 100, 100, 100); // 확인할 영역 좌표 설정 Bitmap bmp = new Bitmap(rect.Width, rect.Height); Graphics gfx = Graphics.FromImage(bmp); gfx.CopyFromScreen(rect.Location, Point.Empty, rect.Size); bool isSame = true; for (int y = 0; y < rect.Height; y++) { for (int x = 0; x < rect.Width; x++) { if (!bmp.GetPixel(x, y).Equals(Color.White)) // 변화가 발생한 경우 { isSame = false; break; } } if (!isSame) { break; } } if (isSame) // 특정 영역에 변화가 없는 경우 { mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); // 마우스 왼쪽 버튼 누르기 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // 마우스 왼쪽 버튼 떼기 } Thread.Sleep(500); // 0.5초 대기 }