Cursor, evet renge tıklıyor, ancak cok ust kısma tıklıyor ve bu yüzden sıkıntı yaşıyorum aşşagıda tıkladıgı yerin linkini veriyorum ;
http://i.hizliresim.com/8gQvEk.png
Bu mousenin biraz daha aşşagıya tıklamasını saglayabilir miyim? nereyi düzeltmem gerekiyor? Yardımlarınızı bekliyorum teşekkürer.
Kodlar ;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LegendryLooter
{
public class ClickManager
{
#region Fields - Properties
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public Rectangle ScanBounds { get; set; }
public Point MatchArea { get; set; }
public Point[] ColorMatch { get; set; }
public int Interval { get; set; }
#endregion
public void Check()
{
Bitmap map = GetScreenshot();
for (int x = ScanBounds.Left; x < ScanBounds.Width + ScanBounds.Left; x++)
{
for (int y = ScanBounds.Top; y < ScanBounds.Height + ScanBounds.Top; y++)
{
if (x > map.Width || y > map.Height)
continue;
bool skip = false;
for (int px = 0; px < MatchArea.X; px++)
{
for (int py = 0; py < MatchArea.Y; py++)
{
Color color = map.GetPixel(x + px, y + py);
if (!CheckColor(color))
{
skip = true;
break;
}
}
if (skip)
break;
}
if (skip)
continue;
int clickX = x + MatchArea.X/2;
int clickY = y + MatchArea.Y/2;
ClickMouse(clickX, clickY);
return;
}
}
}
private bool CheckColor(Color color)
{
return color.R >= ColorMatch[0].X && color.R <= ColorMatch[0].Y &&
color.G >= ColorMatch[1].X && color.G <= ColorMatch[1].Y &&
color.B >= ColorMatch[2].X && color.B <= ColorMatch[2].Y;
}
private Bitmap GetScreenshot()
{
Rectangle s_rect = Screen.PrimaryScreen.Bounds;
Bitmap bmp = new Bitmap(s_rect.Width, s_rect.Height);
using (Graphics gScreen = Graphics.FromImage(bmp))
gScreen.CopyFromScreen(s_rect.Location, Point.Empty, s_rect.Size);
return bmp;
}
private void ClickMouse(int x, int y)
{
SetCursorPos(x,y);
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
}
}