Example #1
0
        public static void startDefaultScript()
        {
            if (ProjectPath != null && ProjectName != null && waitTime != null)
            {
                AutomationFunctions autoFunc = new AutomationFunctions();
                string[]            invokeArray;
                string   invokeText;
                string   name;
                string[] attri;
                string   attri1;
                string   attri2;
                string   attri3;

                //Start Script
                using (StreamReader sw = new StreamReader(ProjectPath + "\\" + ScriptName))
                {
                    string line;
                    while ((line = sw.ReadLine()) != null)
                    {
                        if (!line.StartsWith("//"))
                        {
                            string[] parsed = line.Split('|');
                            name = parsed[0];

                            attri = parsed[2].Split('-');
                            try
                            {
                                processName = attri[2].Substring(2, attri[2].Length - 2);
                            }
                            catch { }
                            autoFunc.SetFocusMainWindow(processName);
                            if (parsed[1].Contains("Button Press"))
                            {
                                autoFunc.ClickButtonWithName(name, processName);
                            }
                            else
                            if (parsed[1].Contains("Click Pane"))
                            {
                                autoFunc.ClickPanelWithName(name, processName);
                            }
                            else
                            if (parsed[1].Contains("Set Text"))
                            {
                                invokeArray = parsed[1].Split(':');
                                invokeText  = invokeArray[1];
                                autoFunc.InsertText(name, processName, invokeText);
                            }
                            else
                            if (parsed[1].Contains("Select Item"))
                            {
                                invokeArray = parsed[1].Split(':');
                                invokeText  = invokeArray[1];
                                autoFunc.SetItem(name, processName, invokeText);
                            }
                            else
                            if (parsed[1].Contains("Set Focus"))
                            {
                                //NOT WORKING YET
                            }
                            else
                            if (parsed[1].Contains("Write Memory Mapped File"))
                            {
                                string mmfName    = parsed[2].Split(':')[0];
                                string mmfDescrip = parsed[2].Split(':')[1];
                                mmf = autoFunc.writeMMF(mmfName, mmfDescrip);
                            }
                            else
                            if (parsed[1].Contains("Close Memory Mapped File"))
                            {
                                autoFunc.closeMMF(mmf);
                            }
                            else
                            if (parsed[1].Contains("Send Message"))
                            {
                                SendKeys.SendWait(parsed[2]);
                            }
                            else
                            if (parsed[1].Contains("Sleep"))
                            {
                                Thread.Sleep(Convert.ToInt32(parsed[2]));
                            }
                            Thread.Sleep(waitTime);
                        }
                    }
                }
            }
        }
Example #2
0
        private static void DoChunk(string line, AutomationFunctions autoFunc)
        {
            string[] invokeArray;
            string   invokeText;
            string   name;

            string[] attri;
            string   attri1;
            string   attri2;
            string   attri3;

            string[] parsed = line.Split('|');
            name = parsed[0];

            attri = parsed[2].Split('-');
            try
            {
                processName = attri[2].Substring(2, attri[2].Length - 2);
            }
            catch { }
            autoFunc.SetFocusMainWindow(processName);
            if (parsed[1].Contains("Button Press"))
            {
                try
                {
                    autoFunc.ClickButtonWithName(name, processName);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Click Pane"))
            {
                try
                {
                    autoFunc.ClickPanelWithName(name, processName);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Set Text"))
            {
                try
                {
                    invokeArray = parsed[1].Split(':');
                    invokeText  = invokeArray[1];
                    autoFunc.InsertText(name, processName, invokeText);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Select Item"))
            {
                try
                {
                    invokeArray = parsed[1].Split(':');
                    invokeText  = invokeArray[1];
                    autoFunc.SetItem(name, processName, invokeText);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Set Focus"))
            {
                //NOT WORKING YET
            }
            else
            if (parsed[1].Contains("Write Memory Mapped File"))
            {
                try
                {
                    string mmfName    = parsed[2].Split(':')[0];
                    string mmfDescrip = parsed[2].Split(':')[1];
                    mmf = autoFunc.writeMMF(mmfName, mmfDescrip);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Close Memory Mapped File"))
            {
                try
                {
                    autoFunc.closeMMF(mmf);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Send Message"))
            {
                try
                {
                    SendKeys.SendWait(parsed[2]);
                }
                catch { }
            }
            else
            if (parsed[1].Contains("Sleep"))
            {
                try
                {
                    Thread.Sleep(Convert.ToInt32(parsed[2]));
                }
                catch { }
            }
            else
            if (parsed[1].Contains("END"))
            {
                hasEnded = true;
            }
        }