Beispiel #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;
        }
Beispiel #2
0
 private IntPtr LowLevelKeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode < 0)
     {
         return(CppLib.CallNextHookEx(CppLib.m_hHook, nCode, wParam, lParam));
     }
     else
     {
         var khs = (CppLib.KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(CppLib.KeyboardHookStruct));
         if (khs.VirtualKeyCode == (int)VirtualKeyStates.VK_ESCAPE)
         {
             Stop = true;
         }
         return(CppLib.CallNextHookEx(CppLib.m_hHook, nCode, wParam, lParam));
     }
 }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();
            options = LoadOptions();
            UpdatecbProgram();
            LoadcbScript();

            gvcCommand.Width = gvcProgram.Width = gvcTypeCommand.Width = window.Width / 3.3;

            sblScreen.Content = "X: " + SystemParameters.PrimaryScreenWidth + " Y: " + SystemParameters.PrimaryScreenHeight;
            System.Drawing.Point mousePosition = System.Windows.Forms.Cursor.Position;
            sblMousePoint.Content   = "X: " + mousePosition.X + " Y: " + mousePosition.Y;
            timerStatusBar          = new DispatcherTimer();
            timerStatusBar.Tick    += new EventHandler(timerStatusBar_Tick);
            timerStatusBar.Interval = new TimeSpan(0, 0, 1);
            timerStatusBar.Start();
            UserList = new List <ScriptItem>();

            m_callback = LowLevelKeyboardHookProc;
            CppLib.SetHook(m_callback);
        }
Beispiel #4
0
        private void cbProgram_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            bAddCommand.IsEnabled = false;
            if (cbProgram.SelectedItem != null)
            {
                if (cbProgram.SelectedItem.ToString() == "Системные команды")
                {
                    lTypeCommand.Content = "Тип команды: ";
                    cbTypeCommand.Items.Clear();
                    cbTypeCommand.Items.Add("Кнопки мыши");
                    cbTypeCommand.Items.Add("Перемещение мыши");
                    cbTypeCommand.Items.Add("Ожидание");
                    cbTypeCommand.Items.Add("Повтор");
                }
                else
                {
                    lTypeCommand.Content = "Компонент: ";
                    cbTypeCommand.Items.Clear();

                    CppLib.ProcessInfo     buff = Proc.Find(x => x.Name == cbProgram.SelectedItem.ToString());
                    List <CppLib.ChildEll> ell  = CppLib.GetNeedChildEll(buff.Handle, options.Ellements.ToArray());
                    for (int i = 0; i < ell.Count; i++)
                    {
                        if (ell[i].Name == "")
                        {
                            cbTypeCommand.Items.Add(i + "." + ell[i].ClassEll);
                        }
                        else
                        {
                            cbTypeCommand.Items.Add(i + "." + ell[i].ClassEll + " \"" + ell[i].Name.Replace("&", "") + "\"");
                        }
                    }

                    cbTypeCommand.Items.Add(ell.Count + ".Контекстное меню");
                }
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        private void bExeScript_Click(object sender, RoutedEventArgs e)
        {
            List <int[]> Repeat   = new List <int[]>();
            int          counter  = options.CounterStart;
            int          counter2 = 0;

            UpdatecbProgram();
            Stop = false;
            for (int i = 0; i < lvScript.Items.Count; i++)
            {
                lvScript.SelectedIndex = i;

                UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(lvScript.SetValue);
                Dispatcher.Invoke(updatePbDelegate, DispatcherPriority.Background, new object[] { System.Windows.Controls.ListView.SelectedIndexProperty, i });

                UpdateProgressBarDelegate updatePbDelegate2 = new UpdateProgressBarDelegate(sblInfo.SetValue);
                if (Repeat.Count > counter2)
                {
                    Dispatcher.Invoke(updatePbDelegate2, DispatcherPriority.Background, new object[] { System.Windows.Controls.Label.ContentProperty, "Осталось ещё " + Repeat[counter2][0] + " повторов" });
                }

                ScriptItem item = new ScriptItem {
                    Program = ((ScriptItem)lvScript.Items[i]).Program, TypeCommand = ((ScriptItem)lvScript.Items[i]).TypeCommand, Command = ((ScriptItem)lvScript.Items[i]).Command
                };

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

                while (true)
                {
                    if (cbCounter.IsChecked == true && item.Command.Contains(options.CounterText) == true)
                    {
                        string buff2 = item.Command.Remove(item.Command.IndexOf(options.CounterText));
                        buff2        = buff2 + counter + item.Command.Remove(0, item.Command.IndexOf(options.CounterText) + options.CounterText.Length);
                        item.Command = buff2;
                    }
                    else
                    {
                        break;
                    }
                }

                switch (item.TypeCommand)
                {
                case "Кнопки мыши":
                    switch (item.Command)
                    {
                    case "Правая кнопка мыши":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Right_Click);
                        break;

                    case "Левая кнопка мыши":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Left_Click);
                        break;

                    case "Правая кнопка мыши вниз":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Right_Down);
                        break;

                    case "Правая кнопка мыши вверх":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Right_Up);
                        break;

                    case "Левая кнопка мыши вниз":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Left_Down);
                        break;

                    case "Левая кнопка мыши вверх":
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Left_Up);
                        break;
                    }
                    break;

                case "Перемещение мыши":
                    System.Windows.Forms.Cursor.Position = new System.Drawing.Point(Convert.ToInt32(item.Command.Split(' ')[1]), Convert.ToInt32(item.Command.Split(' ')[3]));
                    break;

                case "Ожидание":
                    long tiks = DateTime.Now.Ticks + (long)(Convert.ToDouble(item.Command.Split(' ')[0].Replace('.', ',')) * 10000000);
                    while (true)
                    {
                        if (DateTime.Now.Ticks >= tiks)
                        {
                            break;
                        }

                        Dispatcher.Invoke(updatePbDelegate, DispatcherPriority.Background, new object[] { System.Windows.Controls.ListView.SelectedIndexProperty, i });

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

                case "Повтор":
                    counter  = counter + options.CounterStep;
                    counter2 = 0;
                    for (int j = 0; j < Repeat.Count + 1; j++)
                    {
                        if (j == Repeat.Count)
                        {
                            for (int k = 0; k < Repeat.Count; k++)
                            {
                                Repeat[k][0] = Repeat[k][1];
                            }
                            Repeat.Add(new int[3] {
                                Convert.ToInt32(item.Command), Convert.ToInt32(item.Command), i
                            });
                            counter2 = j;
                            break;
                        }
                        if (Repeat[j][2] == i)
                        {
                            counter2 = j;
                            break;
                        }
                    }

                    if (Repeat[counter2][0] != 0)
                    {
                        Repeat[counter2][0]--;
                        i = -1;
                        continue;
                    }
                    break;

                default:
                    UpdatecbProgram();

                    CppLib.ProcessInfo Process = Proc.Find(x => x.Name == item.Program);

                    List <CppLib.ChildEll> ellements = CppLib.GetNeedChildEll(Process.Handle, options.Ellements.ToArray());
                    string   spliteType   = item.TypeCommand.Split(' ')[0];
                    string[] splitCommand = item.Command.Split(' ');
                    string   number       = spliteType.Remove(spliteType.IndexOf('.'), spliteType.Length - 1);
                    string   name         = spliteType.Remove(0, spliteType.IndexOf('.') + 1);
                    if (name == "Контекстное")
                    {
                        Bitmap   screenAfterClick, screenBeforClick;
                        Graphics graphScreenAfterClick, graphScreenBeforClick;
                        System.Drawing.Color[] colorsScreenAfterClick, colorsScreenBeforClick;

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

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


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

                        System.Windows.Forms.Cursor.Position = new System.Drawing.Point(Convert.ToInt32(splitCommand[1]), Convert.ToInt32(splitCommand[3]));
                        CppLib.MouseClickOnDesktop(MyMouseEvent.Mouse_Right_Click);

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

                        colorsScreenBeforClick = GetColorArr(screenBeforClick);

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

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

                        graphScreenAfterClick.CopyFromScreen(new System.Drawing.Point(Process.Border.left, Process.Border.top), System.Drawing.Point.Empty, new System.Drawing.Size(Process.Border.right - Process.Border.left, Process.Border.bottom - Process.Border.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 * screenBeforClick.Width]);
                            }
                        }
                        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 * screenBeforClick.Width]);
                            }
                        }
                        image.Source = BitmapToImageSource(screenAfterClick);
                    }
                    else
                    {
                        for (int j = 0; j < ellements.Count; j++)
                        {
                            if (name == "Edit" && j == Convert.ToInt32(number))
                            {
                                for (int k = 0; k < cbTypeCommand.Items.Count; k++)
                                {
                                    if (number + ".Edit" == cbTypeCommand.Items[k].ToString().Split(' ')[0])
                                    {
                                        cbTypeCommand.Items[k] = number + ".Edit \"" + item.Command + "\"";
                                        break;
                                    }
                                }
                                CppLib.SetTitleText(ellements[j].Handle, item.Command);
                                break;
                            }
                            if (name == "Button" && j == Convert.ToInt32(number))
                            {
                                CppLib.ClickButton(ellements[j].Handle);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            sblInfo.Content = "";
        }