Im getting this error when trying to run a program in creating, how shold i interpet the error message, the macro runs just fine for many loops but then just suddely it breaks, giving this error.
************** Exception Text **************
System.ArgumentException: Value of '-1' is not valid for 'blue'. 'blue' should be greater than or equal to 0 and less than or equal to 255.
at System.Drawing.Color.CheckByte(Int32 value, String name)
at System.Drawing.Color.FromArgb(Int32 alpha, Int32 red, Int32 green, Int32 blue)
at System.Drawing.Color.FromArgb(Int32 red, Int32 green, Int32 blue)
at Dispatcher_Tool.ColorCheck.GetPixelAtCursor()
at Dispatcher_Tool.ColorCheck.getPixel()
at Dispatcher_Tool.ColorCheck.checkColorBlack(Int32 blackCordsX, Int32 blackCordsY)
at Dispatcher_Tool.main_normal.checkColor()
at Dispatcher_Tool.main_normal.startMacro(TextBox valX)
at Dispatcher_Tool.main_normal.button5_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
code around this point is,
[DllImport("gdi32")]
private static extern int GetPixel(IntPtr hdc, int x, int y);
[DllImport("User32")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);
#region Pixel color test
private static readonly IntPtr DesktopDC = GetWindowDC(IntPtr.Zero);
public static System.Drawing.Color GetPixelAtCursor()
{
System.Drawing.Point p = Cursor.Position;
int color = GetPixel(DesktopDC, p.X, p.Y);
return System.Drawing.Color.FromArgb(color & 0xFF, color >> 8 & 0xFF, color >> 16);
}