using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Windows.Forms; class Program { // WinAPI işlevi: Fare hareketini simüle etme [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern void SetCursorPos(int X, int Y); // WinAPI işlevi: Fare tıklamasını simüle etme [DllImport("user32.dll")] private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, IntPtr dwExtraInfo); private const uint MOUSEEVENTF_LEFTDOWN = 0x0002; private const uint MOUSEEVENTF_LEFTUP = 0x0004; // Ekran görüntüsü almak için bir method static Bitmap CaptureScreen() { Rectangle bounds = Screen.GetBounds(Point.Empty); Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } return bitmap; } // Ekran görüntüsü üzerinde belirli bir rengin aranması static Point? FindColor(Bitmap bitmap, Color colorToFind) { for (int x = 0; x < bitmap.Width; x++) { for (int y = 0; y < bitmap.Height; y++) { Color pixelColor = bitmap.GetPixel(x, y); if (pixelColor == colorToFind) { return new Point(x, y); } } } return null; } // Fare hareketini simüle etme static void MoveMouseTo(Point point) { SetCursorPos(point.X, point.Y); } // Fare tıklamasını simüle etme static void ClickMouse() { mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero); } static void Main() { // Renk arama örneği Bitmap screenCapture = CaptureScreen(); Color colorToFind = Color.Red; // Aranacak renk Point? foundPoint = FindColor(screenCapture, colorToFind); if (foundPoint.HasValue) { Console.WriteLine($"Color found at: {foundPoint.Value}"); // Fareyi bulduğu noktaya hareket ettirme MoveMouseTo(foundPoint.Value); // Fare tıklamasını simüle etme ClickMouse(); } else { Console.WriteLine("Color not found."); } } } BU KODU GELİŞTİRİP KULLANABİLİRSİN
using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Windows.Forms; class Program { // WinAPI işlevi: Fare hareketini simüle etme [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern void SetCursorPos(int X, int Y); // WinAPI işlevi: Fare tıklamasını simüle etme [DllImport("user32.dll")] private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, IntPtr dwExtraInfo); private const uint MOUSEEVENTF_LEFTDOWN = 0x0002; private const uint MOUSEEVENTF_LEFTUP = 0x0004; // Ekran görüntüsü almak için bir method static Bitmap CaptureScreen() { Rectangle bounds = Screen.GetBounds(Point.Empty); Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } return bitmap; } // Ekran görüntüsü üzerinde belirli bir rengin aranması static Point? FindColor(Bitmap bitmap, Color colorToFind) { for (int x = 0; x < bitmap.Width; x++) { for (int y = 0; y < bitmap.Height; y++) { Color pixelColor = bitmap.GetPixel(x, y); if (pixelColor == colorToFind) { return new Point(x, y); } } } return null; } // Fare hareketini simüle etme static void MoveMouseTo(Point point) { SetCursorPos(point.X, point.Y); } // Fare tıklamasını simüle etme static void ClickMouse() { mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero); } static void Main() { // Renk arama örneği Bitmap screenCapture = CaptureScreen(); Color colorToFind = Color.Red; // Aranacak renk Point? foundPoint = FindColor(screenCapture, colorToFind); if (foundPoint.HasValue) { Console.WriteLine($"Color found at: {foundPoint.Value}"); // Fareyi bulduğu noktaya hareket ettirme MoveMouseTo(foundPoint.Value); // Fare tıklamasını simüle etme ClickMouse(); } else { Console.WriteLine("Color not found."); } } } BU KODU GELİŞTİRİP KULLANABİLİRSİN
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms;
class Program
{
// WinAPI işlevi: Fare hareketini simüle etme
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern void SetCursorPos(int X, int Y);
// WinAPI işlevi: Fare tıklamasını simüle etme
[DllImport("user32.dll")]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, IntPtr dwExtraInfo);
private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
private const uint MOUSEEVENTF_LEFTUP = 0x0004;
// Ekran görüntüsü almak için bir method
static Bitmap CaptureScreen()
{
Rectangle bounds = Screen.GetBounds(Point.Empty);
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
return bitmap;
}
// Ekran görüntüsü üzerinde belirli bir rengin aranması
static Point? FindColor(Bitmap bitmap, Color colorToFind)
{
for (int x = 0; x < bitmap.Width; x++)
{
for (int y = 0; y < bitmap.Height; y++)
{
Color pixelColor = bitmap.GetPixel(x, y);
if (pixelColor == colorToFind)
{
return new Point(x, y);
}
}
}
return null;
}
// Fare hareketini simüle etme
static void MoveMouseTo(Point point)
{
SetCursorPos(point.X, point.Y);
}
// Fare tıklamasını simüle etme
static void ClickMouse()
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero);
}
static void Main()
{
// Renk arama örneği
Bitmap screenCapture = CaptureScreen();
Color colorToFind = Color.Red; // Aranacak renk
Point? foundPoint = FindColor(screenCapture, colorToFind);
if (foundPoint.HasValue)
{
Console.WriteLine($"Color found at: {foundPoint.Value}");
// Fareyi bulduğu noktaya hareket ettirme
MoveMouseTo(foundPoint.Value);
// Fare tıklamasını simüle etme
ClickMouse();
}
else
{
Console.WriteLine("Color not found.");
}
}
}
daha düzgün kopyalanmış hali bu kodu kendin üzerinde çalışıp düzeltebilirsin sana yanına yazarak hafif tüyolar verdim kod teoride doğru fakat yetersiz