예제 #1
0
        void UpdatecbProgram()
        {
            Proc = CppLib.GetProcessList();
            cbProgram.Items.Clear();
            cbCommand.SelectedIndex = -1;
            int OldCount = Proc.Count;

            for (int i = 0; i < OldCount; i++)
            {
                cbProgram.Items.Add(Proc[i].Name);
                for (int j = 0; j < options.ChildWindows.Count; j++)
                {
                    IntPtr handle;
                    if ((handle = CppLib.GetChildWindowHandle(options.ChildWindows[j], Proc[i].Handle)) != IntPtr.Zero)
                    {
                        CppLib.Rect rect = new CppLib.Rect();
                        CppLib.GetWindowRect(handle, ref rect);
                        /*Запомнить на будущее*/
                        //Proc.Add(new CppLib.ProcessInfo { Handle = handle, Name = options.ChildWindows[j] + " от " + Proc[i].Name, Border = rect });
                        //cbProgram.Items.Add(options.ChildWindows[j] + " от " + Proc[i].Name);
                        Proc.Add(new CppLib.ProcessInfo {
                            Handle = handle, Name = options.ChildWindows[j], Border = rect
                        });
                        cbProgram.Items.Add(options.ChildWindows[j]);
                    }
                }
            }
            cbProgram.Items.Add("Системные команды");
            cbProgram.SelectedIndex = cbProgram.Items.Count - 1;
        }
예제 #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            CppLib.Rect prob = new CppLib.Rect {
                bottom = 200, left = 100, right = 200, top = 100
            };
            System.Drawing.Point prob2 = new System.Drawing.Point(450, 500);

            Bitmap   screenAfterClick, screenBeforClick;
            Graphics graphScreenAfterClick, graphScreenBeforClick;

            System.Drawing.Color[] colorsScreenAfterClick, colorsScreenBeforClick;

            screenAfterClick      = new Bitmap(prob.right - prob.left, prob.bottom - prob.top);
            graphScreenAfterClick = Graphics.FromImage(screenAfterClick);

            screenBeforClick      = new Bitmap(prob.right - prob.left, prob.bottom - prob.top);
            graphScreenBeforClick = Graphics.FromImage(screenBeforClick);


            graphScreenBeforClick.CopyFromScreen(new System.Drawing.Point(prob.left, prob.top), System.Drawing.Point.Empty, new System.Drawing.Size(prob.right - prob.left, prob.bottom - prob.top));

            System.Windows.Forms.Cursor.Position = new System.Drawing.Point(prob2.X, prob2.Y);
            CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Right_Click);

            long tiks = DateTime.Now.Ticks + (long)(Convert.ToDouble(0.5 * 10000000));

            colorsScreenBeforClick = GetColorArr(screenBeforClick);

            while (true)
            {
                if (DateTime.Now.Ticks >= tiks)
                {
                    break;
                }

                if (Stop == true)
                {
                    sblInfo.Content        = "";
                    Stop                   = false;
                    lvScript.SelectedIndex = lvScript.Items.Count - 1;
                    return;
                }
            }

            graphScreenAfterClick.CopyFromScreen(new System.Drawing.Point(prob.left, prob.top), System.Drawing.Point.Empty, new System.Drawing.Size(prob.right - prob.left, prob.bottom - prob.top));
            colorsScreenAfterClick = GetColorArr(screenAfterClick);

            for (int y = 0; y < screenBeforClick.Height; y++)
            {
                for (int x = 0; x < screenBeforClick.Width; x++)
                {
                    screenBeforClick.SetPixel(x, y, colorsScreenBeforClick[x + y * 100]);
                }
            }
            image1.Source = BitmapToImageSource(screenBeforClick);

            for (int y = 0; y < screenAfterClick.Height; y++)
            {
                for (int x = 0; x < screenAfterClick.Width; x++)
                {
                    screenAfterClick.SetPixel(x, y, colorsScreenAfterClick[x + y * 100]);
                }
            }
            image.Source = BitmapToImageSource(screenAfterClick);
        }