Example #1
0
        private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
        {
            Console.WriteLine("KeyPress: \t{0}", e.KeyChar);
            if (e.KeyChar == (Char)Keys.A)
            {
                Point cursor = new Point();
                GetCursorPos(ref cursor);

                var c = GetColorAt(cursor);
                for (int i = 0; i < colors.Count; i++)
                {
                    Color color = colors[i];
                    if (Math.Abs(c.R - color.R) < 20 &&
                        Math.Abs(c.G - color.G) < 20 &&
                        Math.Abs(c.B - color.B) < 20)
                    {
                        MessageBox.Show("This color is excluded by you");
                        return;
                    }
                }
                FloatingWindow floatingWindow = new FloatingWindow(cursor.X, cursor.Y);
                floatingWindow.BackColor = c;
                Label label    = floatingWindow.Controls.Find("colorText", true).FirstOrDefault() as Label;
                Label position = floatingWindow.Controls.Find("position", true).FirstOrDefault() as Label;
                position.Text = "( " + cursor.X + ", " + cursor.Y + " )";
                label.Text    = "(" + c.R + ", " + c.G + ", " + c.B + " )";
                floatingWindow.Show();
                Application.OpenForms["FloatingWindow"].BringToFront();
            }
        }
Example #2
0
        private void moveWindow(int xPos, int yPos, Color color)
        {
            searchWindow           = new FloatingWindow(xPos, yPos);
            searchWindow.BackColor = color;
            Label label    = searchWindow.Controls.Find("colorText", true).FirstOrDefault() as Label;
            Label position = searchWindow.Controls.Find("position", true).FirstOrDefault() as Label;

            position.Text = "( " + xPos + ", " + yPos + " )";
            label.Text    = "(" + color.R + ", " + color.G + ", " + color.B + " )";
            searchWindow.Show();
            Application.OpenForms["FloatingWindow"].BringToFront();
        }