コード例 #1
0
ファイル: FormRecordMakro.cs プロジェクト: nordie92/Makru
        private void InputDetection_InputDetected1(CommandType inputType, Keys key, int x, int y, bool mouseWheelDirection, bool rightMouseButton)
        {
            if (m_lastCommandTime != DateTime.MinValue)
            {
                CommandWait cw = new CommandWait((int)(DateTime.Now - m_lastCommandTime).TotalMilliseconds, Macro.GetMacroByChild(m_node));
                cw.Duration = Math.Max(cw.Duration, 30);
                m_node.Nodes.Add(cw);
            }

            CommandInput ci = new CommandInput(inputType, key, x, y, mouseWheelDirection, rightMouseButton, Macro.GetMacroByChild(m_node));

            m_node.Nodes.Add(ci);

            m_lastCommandTime = DateTime.Now;
        }
コード例 #2
0
        private void tvMakros_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            tvMakros.SelectedNode = e.Node;

            if (e.Button == MouseButtons.Left)
            {
                if (e.Node.GetType() == typeof(CommandWait))
                {
                    CommandWait c = (CommandWait)tvMakros.SelectedNode;

                    FormCommandWait frm = new FormCommandWait(c.Duration);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        c.Duration = frm.WaitDuration;
                    }
                }
                else if (e.Node.GetType() == typeof(ActivatorShortcut))
                {
                    ActivatorShortcut     a   = (ActivatorShortcut)e.Node;
                    FormActivatorShortcut frm = new FormActivatorShortcut(a.Shortcut, a.LoopexEcution);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        a.Shortcut.Keys = frm.Shortcut.Keys;
                        a.Shortcut      = a.Shortcut;
                        a.LoopexEcution = frm.LoopExecution;
                    }
                }
                else if (e.Node.GetType() == typeof(ActivatorTime))
                {
                    ActivatorTime     a   = (ActivatorTime)e.Node;
                    FormActivatorTime frm = new FormActivatorTime(a.TriggerTime, a.TriggerInterval);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        a.TriggerTime     = frm.TriggerTime;
                        a.TriggerInterval = frm.TriggerInterval;
                    }
                }
                else if (e.Node.GetType() == typeof(CommandInput))
                {
                    Macro            m   = Macro.GetMacroByChild(m_selectedNode);
                    FormCommandInput frm = new FormCommandInput((CommandInput)e.Node, m);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        e.Node.Parent.Nodes.Insert(e.Node.Index, frm.CommandInput);
                        e.Node.Remove();
                    }
                }
                else if (e.Node.GetType() == typeof(ConditionNode))
                {
                    Macro         m  = Macro.GetMacroByChild(tvMakros.SelectedNode);
                    ConditionNode cn = (ConditionNode)e.Node;

                    FormCondition frm = null;
                    if (cn.Condition != null)
                    {
                        frm = new FormCondition(cn.Condition, m);
                    }
                    else
                    {
                        frm = new FormCondition(m);
                    }

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        cn.Condition = frm.Condition;
                    }
                }
                else if (e.Node.GetType() == typeof(CommandSetVariable))
                {
                    CommandSetVariable c = (CommandSetVariable)m_selectedNode;
                    Macro m = Macro.GetMacroByChild(c);
                    FormCommandSetVariable frm = new FormCommandSetVariable((c.Variable != null ? c.Variable.Name : ""), c.Output, m);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        c.Variable = frm.Variable;
                        c.Output   = frm.Output;
                    }
                }
                else if (e.Node.GetType() == typeof(CommandReplayMakro))
                {
                    CommandReplayMakro     c   = (CommandReplayMakro)m_selectedNode;
                    FormCommandReplayMacro frm = new FormCommandReplayMacro(c.MacroName);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        c.MacroName = frm.MacroName;
                    }
                }
                else if (e.Node.GetType() == typeof(CommandWriteFile))
                {
                    Macro                m   = Macro.GetMacroByChild(m_selectedNode);
                    CommandWriteFile     c   = (CommandWriteFile)m_selectedNode;
                    FormCommandWriteFile frm = new FormCommandWriteFile(c.FileName, c.FileText, c.AppendFile, m);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        c.FileName   = frm.FileName;
                        c.FileText   = frm.Text;
                        c.AppendFile = frm.AppendFile;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Macros.cs プロジェクト: nordie92/Makru
        private void Makros_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                ActivatorTime.CancelTimers(SelectedNode);
                ActivatorShortcut.RemoveEvents(SelectedNode);

                if (SelectedNode.GetType() == typeof(ActivatorShortcut))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.GetType() == typeof(ActivatorTime))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "command" || SelectedNode.Name == "activator" || SelectedNode.Name == "condition")
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    DialogResult result = MessageBox.Show("Wollen Sie \"" + SelectedNode.Text + "\" und somit auch alle Unterpunkte wirklich löschen?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        Nodes.Remove(SelectedNode);
                    }
                }
            }
            else if (e.KeyCode == Keys.Add)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration + 50 <= 3600000)
                    {
                        cw.Duration += 50;
                    }
                    else
                    {
                        cw.Duration = 3600000;
                    }
                }
            }
            else if (e.KeyCode == Keys.Subtract)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration - 50 >= 20)
                    {
                        cw.Duration -= 50;
                    }
                    else
                    {
                        cw.Duration = 20;
                    }
                }
            }
            else if (e.KeyCode == Keys.NumPad0)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 40;
                }
            }
            else if (e.KeyCode == Keys.NumPad1)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 100;
                }
            }
            else if (e.KeyCode == Keys.NumPad2)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 200;
                }
            }
            else if (e.KeyCode == Keys.Up && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int tnIndex = SelectedNode.Index;
                    if (tnIndex - 1 >= 0)
                    {
                        TreeNode parentNode = SelectedNode.Parent;
                        TreeNode tn         = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex - 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            else if (e.KeyCode == Keys.Down && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int      tnIndex    = SelectedNode.Index;
                    TreeNode parentNode = SelectedNode.Parent;
                    if (tnIndex + 1 <= parentNode.Nodes.Count)
                    {
                        TreeNode tn = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex + 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            if (e.KeyCode == Keys.ControlKey)
            {
                m_controlPressed = true;
            }
        }
コード例 #4
0
ファイル: Macro.cs プロジェクト: nordie92/Makru
        private void ReadJSONCommand(dynamic json, TreeNode currentNode, int index)
        {
            dynamic d;

            try
            {
                d = json.commands;
            }
            catch (RuntimeBinderException)
            {
                d = json;
            }
            foreach (dynamic command in d)
            {
                switch ((string)command.type)
                {
                case "KeyDown":
                    CommandInput ci1 = new CommandInput(CommandType.KeyDown, command.keyCode.ToObject <Keys>(), 0, 0, false, false, this);
                    currentNode.Nodes.Add(ci1);
                    break;

                case "KeyUp":
                    CommandInput ci2 = new CommandInput(CommandType.KeyUp, command.keyCode.ToObject <Keys>(), 0, 0, false, false, this);
                    currentNode.Nodes.Add(ci2);
                    break;

                case "MouseDown":
                    CommandInput ci3 = new CommandInput(CommandType.MouseDown, Keys.None, command.x.ToObject <int>(), command.y.ToObject <int>(), false, (command.button.ToObject <string>() == "right" ? true : false), this);
                    currentNode.Nodes.Add(ci3);
                    break;

                case "MouseUp":
                    CommandInput ci4 = new CommandInput(CommandType.MouseUp, Keys.None, command.x.ToObject <int>(), command.y.ToObject <int>(), false, (command.button.ToObject <string>() == "right" ? true : false), this);
                    currentNode.Nodes.Add(ci4);
                    break;

                case "MouseMove":
                    CommandInput ci41 = new CommandInput(CommandType.MouseMove, Keys.None, command.x.ToObject <int>(), command.y.ToObject <int>(), false, false, this);
                    currentNode.Nodes.Add(ci41);
                    break;

                case "MouseWheel":
                    CommandInput ci5 = new CommandInput(CommandType.MouseWheel, Keys.None, command.x.ToObject <int>(), command.y.ToObject <int>(), (command.wheelDirection.ToObject <string>() == "up" ? true : false), false, this);
                    currentNode.Nodes.Add(ci5);
                    break;

                case "wait":
                    CommandWait ci6 = new CommandWait(command.duration.ToObject <int>(), this);
                    currentNode.Nodes.Add(ci6);
                    break;

                case "condition":
                    CommandCondition ci8 = new CommandCondition();
                    currentNode.Nodes.Add(ci8);
                    foreach (dynamic j in command.conditions)
                    {
                        ci8.Nodes[0].Nodes.Add(new ConditionNode(ReadJSONCondition(j)));
                    }
                    ReadJSONCommand(command.thenCommands, ci8.Nodes[1], 0);
                    ReadJSONCommand(command.elseCommands, ci8.Nodes[2], 0);
                    break;

                case "replayMacro":
                    CommandReplayMakro ci9 = new CommandReplayMakro((string)command.name, this);
                    currentNode.Nodes.Add(ci9);
                    break;

                case "setVariable":
                    Variable v = new Variable((string)command.variable, "");
                    this.Variables.Add(v);
                    CommandSetVariable ci10 = new CommandSetVariable(v, ReadJSONOutput(command.output), this);
                    currentNode.Nodes.Add(ci10);
                    break;

                case "writeFile":
                    string fileName = (string)command.fileName;
                    fileName = fileName.Replace("\\\\", "\\");
                    CommandWriteFile ci11 = new CommandWriteFile(fileName, (string)command.text, (bool)command.appendFile, this);
                    currentNode.Nodes.Add(ci11);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }