Ejemplo n.º 1
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("PutInternetExplorerTabTitleInEntity"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayPutInternetExplorerTabTitleInEntity:
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp1 = new List <ComboBoxPair>();

            intRowCtr            = 0;
            myListControlEntity1 = new List <ControlEntity>();
            myControlEntity      = new ControlEntity();
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.Heading;
            myControlEntity1.Text        = "Get Active Window Title";
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSyntax2";
            myControlEntity1.Text         = "string [[ResultValue]] = myActions.PutInternetExplorerTabTitleInEntity();";
            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblOutput";
            myControlEntity1.Text         = "Output:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblResultValue";
            myControlEntity1.Text         = "ResultValue:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtResultValue";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorPutInternetExplorerTabTitleInEntityResultValue");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 400, 700, intWindowTop, intWindowLeft);

            string strResultValue = myListControlEntity1.Find(x => x.ID == "txtResultValue").Text;

            // string strShowOption = myListControlEntity1.Find(x => x.ID == "cbxShowOption").SelectedValue;

            myActions.SetValueByKey("ScriptGeneratorPutInternetExplorerTabTitleInEntityResultValue", strResultValue);
            //   myActions.SetValueByKey("ScriptGeneratorShowOption", strShowOption);

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);
            if (strButtonPressed == "btnOkay")
            {
                string strResultValueToUse = "";

                strResultValueToUse = strResultValue.Trim();

                string strGeneratedLinex = "";

                strGeneratedLinex = strResultValueToUse + " = myActions.PutInternetExplorerTabTitleInEntity();";

                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                string strOutFile = strApplicationPath + "TemplateCode3GlobalsNew.txt";
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile))
                {
                    file.WriteLine("static string " + strResultValueToUse + " = \"\";");
                }

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, strResultValueToUse);

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============

                myActions.PutEntityInClipboard(strGeneratedLinex);

                myActions.MessageBoxShow(strGeneratedLinex + Environment.NewLine + Environment.NewLine + "The generated text has been put into your clipboard");
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("TestDynamicCompiler"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            var           logFile = File.ReadAllLines(@"c:\Data\myfile.txt");
            var           logList = new List <string>(logFile);
            StringBuilder sb1     = new StringBuilder();

            foreach (var item in logList)
            {
                sb1.AppendLine(item);
                if (item.EndsWith(";"))
                {
                    // might be able to log line number
                }
            }
            string code = @"
                using System;
                using IdealAutomate.Core; " +
                          "using System.Windows; \r\n" +
                          "using IdealAutomate.Core; \r\n" +
                          "using System.Collections.Generic; \r\n" +
                          "using Microsoft.CSharp; \r\n" +
                          "using System.CodeDom.Compiler; \r\n" +
                          "using System.Reflection; \r\n" +
                          "using System.Text; \r\n" +
                          "using System; \r\n" +
                          "using System.Linq; \r\n" +
                          "using System.IO; \r\n" +
                          @" namespace First
                {
                    public class Program
                    {
                        public static void Main()
                        {
                        " +
                          "Methods myActions = new Methods();" +
                          sb1.ToString()
                          + @"
                        }
                    }
                }
            ";

            CSharpCodeProvider provider   = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();

            // Reference to System.Drawing library
            var assemblies = AppDomain.CurrentDomain
                             .GetAssemblies()
                             .Where(a => !a.IsDynamic)
                             .Select(a => a.Location);


            parameters.ReferencedAssemblies.AddRange(assemblies.ToArray());
            // True - memory generation, false - external file generation
            parameters.GenerateInMemory = true;
            // True - exe file generation, false - dll file generation
            parameters.GenerateExecutable = true;

            CompilerResults results = provider.CompileAssemblyFromSource(parameters, code);

            if (results.Errors.HasErrors)
            {
                StringBuilder sb = new StringBuilder();

                foreach (CompilerError error in results.Errors)
                {
                    sb.AppendLine(String.Format("Error ({0}): {1}", error.ErrorNumber, error.ErrorText));
                }

                throw new InvalidOperationException(sb.ToString());
            }

            Assembly   assembly = results.CompiledAssembly;
            Type       program  = assembly.GetType("First.Program");
            MethodInfo main     = program.GetMethod("Main");

            try {
                main.Invoke(null, null);
            } catch (Exception ex) {
                myActions.MessageBoxShow(ex.Message);
                if (ex.InnerException != null)
                {
                    myActions.MessageBoxShow(ex.InnerException.ToString());
                }
            }

            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            if (myWebSite == "http://www.google.com")
            {
                myActions.TypeText("%(d)", 500);
                myActions.TypeText("{ESC}", 500);
                myActions.TypeText("{F6}", 500);
                myActions.TypeText("{TAB}", 500);
                myActions.TypeText("{TAB 2}", 500);
                myActions.TypeText("{ESC}", 500);
            }
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"");
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgPatch2015_08_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgPatch2015_08.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 30;
            myImage.RelativeY = 10;


            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of " + myImage.ImageFile);
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.RightClick(myArray);

            myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            string officePath = myActions.GetValueByKeyGlobalRespondWithDialogIfEmpty("OfficePath");

            myActions.Run(System.IO.Path.Combine(officePath, "EXCEL.EXE"), @"C:\SVNStats\SVNStats.xlsx");
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("HelloWorldExample"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intRowCtr           = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lblHelloWorldExample";
            myControlEntity.Text         = "Hello World Example";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblSearchEngine";
            myControlEntity.Text         = "Search Engine";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("google.com", "google.com"));
            cbp.Add(new ComboBoxPair("yahoo.com", "yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "yahoo.com";
            myControlEntity.ID           = "cbxSearchEngine";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ToolTipx     = "";
            myControlEntity.DDLName      = "";
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblSearchTerm";
            myControlEntity.Text         = "SearchTerm";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtSearchTerm";
            myControlEntity.Text         = "Hello World";
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string strSearchEngine = myListControlEntity.Find(x => x.ID == "cbxSearchEngine").SelectedValue;
            string strSearchTerm   = myListControlEntity.Find(x => x.ID == "txtSearchTerm").Text;

            myActions.IEGoToURL(myActions, strSearchEngine, true);
            myActions.TypeText("{ESCAPE}", 4000); // escape
            myActions.TypeText(strSearchTerm, 4000);
            myActions.TypeText("{ENTER}", 4000);  // enter.
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("FindValueInAnyTableInDB"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            myActions.DebugMode = true;
            string myBigSqlString    = "";
            string junk              = "";
            string strScriptName     = "FindValueInAnyTableInDB";
            string settingsDirectory = GetAppDirectoryForScript(strScriptName);
            string fileName;
            string strSavedDomainName;

            fileName           = "DomainName.txt";
            strSavedDomainName = ReadValueFromAppDataFile(settingsDirectory, fileName);
            if (strSavedDomainName == "")
            {
                strSavedDomainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
            }

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            ControlEntity        myControlEntity     = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Domain Name";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Enter Domain Name";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myDomainName";
            myControlEntity.Text         = strSavedDomainName;
            myControlEntity.ToolTipx     = "To find Windows Domain, Open the Control Panel, click the System and Security " + System.Environment.NewLine + "category, and click System. Look under “Computer name, " + System.Environment.NewLine + "domain and workgroup settings” here. If you see “Domain”:" + System.Environment.NewLine + "followed by the name of a domain, your computer is joined to a domain." + System.Environment.NewLine + "Most computers running at home do not have a domain as they do" + System.Environment.NewLine + "not use Active Directory";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "mylabel";
            myControlEntity.ColumnSpan   = 2;
            myControlEntity.Text         = "(Leave domain name blank if not using server in Active Directory)";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.Checked      = true;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string strDomainName = myListControlEntity.Find(x => x.ID == "myDomainName").Text;

            fileName = "DomainName.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, strDomainName);

            ArrayList     myServers        = new ArrayList();
            List <string> servers          = new List <string>();
            List <string> listLocalServers = new List <string>();

            // Get servers from the registry (if any)
            RegistryKey key = RegistryKey.OpenBaseKey(
                Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);

            key = key.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
            object installedInstances = null;

            if (key != null)
            {
                installedInstances = key.GetValue("InstalledInstances");
            }
            List <string> instances = null;

            if (installedInstances != null)
            {
                instances = ((string[])installedInstances).ToList();
            }
            if (System.Environment.Is64BitOperatingSystem)
            {
                /* The above registry check gets routed to the syswow portion of
                 * the registry because we're running in a 32-bit app. Need
                 * to get the 64-bit registry value(s) */
                key = RegistryKey.OpenBaseKey(
                    Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
                key = key.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
                installedInstances = null;
                if (key != null)
                {
                    installedInstances = key.GetValue("InstalledInstances");
                }
                string[] moreInstances = null;
                if (installedInstances != null)
                {
                    moreInstances = (string[])installedInstances;
                    if (instances == null)
                    {
                        instances = moreInstances.ToList();
                    }
                    else
                    {
                        instances.AddRange(moreInstances);
                    }
                }
            }
            foreach (string item in instances)
            {
                string name = System.Environment.MachineName;
                if (item != "MSSQLSERVER")
                {
                    name += @"\" + item;
                }
                if (!servers.Contains(name.ToUpper()))
                {
                    myServers.Add(name.ToUpper());
                    listLocalServers.Add(name.ToUpper());
                }
            }

            try {
                string myldap = FriendlyDomainToLdapDomain(strDomainName);

                string         distinguishedName = string.Empty;
                string         connectionPrefix  = "LDAP://" + myldap;
                DirectoryEntry entry             = new DirectoryEntry(connectionPrefix);

                DirectorySearcher mySearcher = new DirectorySearcher(entry);
                mySearcher.Filter   = "(&(objectClass=Computer)(operatingSystem=Windows Server*) (!cn=wde*))";
                mySearcher.PageSize = 1000;
                mySearcher.PropertiesToLoad.Add("name");

                SearchResultCollection result = mySearcher.FindAll();
                foreach (SearchResult item in result)
                {
                    // Get the properties for 'mySearchResult'.
                    ResultPropertyCollection myResultPropColl;

                    myResultPropColl = item.Properties;

                    foreach (Object myCollection in myResultPropColl["name"])
                    {
                        myServers.Add(myCollection.ToString());
                    }
                }

                entry.Close();
                entry.Dispose();
                mySearcher.Dispose();
            } catch (Exception) {
                // do not show exception because they may not be using active directory
            }
            myServers.Sort();
            fileName = "Servers.txt";
            WriteArrayListToAppDirectoryFile(settingsDirectory, fileName, myServers);

            myListControlEntity = new List <ControlEntity>();
            myControlEntity     = new ControlEntity();
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Select Server";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Server";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            fileName  = "Servers.txt";
            myServers = ReadAppDirectoryFileToArrayList(settingsDirectory, fileName);
            foreach (var item in myServers)
            {
                cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
            }
            myControlEntity.ListOfKeyValuePairs = cbp;
            fileName = "ServerSelectedValue.txt";
            myControlEntity.SelectedValue = ReadValueFromAppDataFile(settingsDirectory, fileName);
            myControlEntity.RowNumber     = 0;
            myControlEntity.ColumnNumber  = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            int intRowCtr = 1;

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblAlternateServer";
            myControlEntity.Text         = "Alternate Server";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.TextBox;
            myControlEntity.ID          = "txtAlternateServer";
            fileName                     = "txtAlternateServer.txt";
            myControlEntity.Text         = ReadValueFromAppDataFile(settingsDirectory, fileName);
            myControlEntity.ToolTipx     = "If server was not in dropdown, you can type it here; otherwise, leave blank";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblUserName";
            myControlEntity.Text         = "UserName";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.TextBox;
            myControlEntity.ID          = "txtUserName";
            fileName                     = "txtUserName.txt";
            myControlEntity.Text         = ReadValueFromAppDataFile(settingsDirectory, fileName);
            myControlEntity.ToolTipx     = "User Name for logging into server";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblPassword";
            myControlEntity.Text         = "Password";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.PasswordBox;
            myControlEntity.ID          = "txtPassword";
            fileName = "txtPss.txt";
            string strPass             = "";
            string inputFullFileName1  = Path.Combine(settingsDirectory, fileName.Replace(".", "Encrypted."));
            string outputFullFileName1 = Path.Combine(settingsDirectory, fileName);

            if (File.Exists(inputFullFileName1))
            {
                EncryptDecrypt ed1 = new EncryptDecrypt();
                ed1.DecryptFile(inputFullFileName1, outputFullFileName1);
                strPass = ReadValueFromAppDataFile(settingsDirectory, fileName);
            }
            File.Delete(outputFullFileName1);
            myControlEntity.Text         = strPass;
            myControlEntity.ToolTipx     = "Password for logging into server";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Remember Password";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            fileName = "RememberPassword.txt";
            string strRememberPassword = ReadValueFromAppDataFile(settingsDirectory, fileName);

            if (strRememberPassword.ToLower() == "true")
            {
                myControlEntity.Checked = true;
            }
            else
            {
                myControlEntity.Checked = false;
            }
            myControlEntity.ForegroundColor = System.Windows.Media.Colors.Red;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            bool boolRememberPassword = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            fileName = "RememberPassword.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, boolRememberPassword.ToString());
            string strServerName = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            fileName = "ServerSelectedValue.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, strServerName);
            string strAlternateServer = myListControlEntity.Find(x => x.ID == "txtAlternateServer").Text;

            fileName = "txtAlternateServer.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, strAlternateServer);
            string strUserName = myListControlEntity.Find(x => x.ID == "txtUserName").Text;

            fileName = "txtUserName.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, strUserName);
            string strPassword = myListControlEntity.Find(x => x.ID == "txtPassword").Text;

            fileName = "txtPss.txt";
            if (boolRememberPassword)
            {
                WriteValueToAppDirectoryFile(settingsDirectory, fileName, strPassword);
                string         inputFullFileName  = Path.Combine(settingsDirectory, fileName);
                string         outputFullFileName = Path.Combine(settingsDirectory, fileName.Replace(".", "Encrypted."));
                EncryptDecrypt ed = new EncryptDecrypt();
                ed.EncryptFile(inputFullFileName, outputFullFileName);
                File.Delete(inputFullFileName);
            }

            if (strAlternateServer.Trim() != "")
            {
                strServerName = strAlternateServer;
            }

            myListControlEntity = new List <ControlEntity>();

            myControlEntity = new ControlEntity();
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Select Database";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Database";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            ArrayList myDatabases       = new ArrayList();
            string    strSelectedServer = strServerName;
            DataTable dtDatabases       = GetDatabases(strSelectedServer, strUserName, strPassword);

            try {
                for (int i = 0; i < dtDatabases.Rows.Count; i++)
                {
                    DataRow dr = dtDatabases.Rows[i];
                    myDatabases.Add(dr["sysdbreg_name"]);
                }
            } catch (Exception ex) {
                string exception = ex.Message;
                myActions.MessageBoxShow(exception);
            }

            fileName = "Databases.txt";
            WriteArrayListToAppDirectoryFile(settingsDirectory, fileName, myDatabases);
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "";
            cbp         = new List <ComboBoxPair>();
            fileName    = "Databases.txt";
            myDatabases = ReadAppDirectoryFileToArrayList(settingsDirectory, fileName);
            foreach (var item in myDatabases)
            {
                cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
            }
            myControlEntity.ListOfKeyValuePairs = cbp;
            fileName = "DatabaseSelectedValue.txt";
            myControlEntity.SelectedValue = ReadValueFromAppDataFile(settingsDirectory, fileName);
            myControlEntity.RowNumber     = 0;
            myControlEntity.ColumnNumber  = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr = 0;

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Search for Value";
            myControlEntity.RowNumber    = 3;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "";
            myControlEntity.RowNumber    = 3;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblContainsEqual";
            myControlEntity.Text         = "ContainsEqual";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            List <ComboBoxPair> cbp1 = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp1.Clear();
            cbp1.Add(new ComboBoxPair("Contains", "Contains"));
            cbp1.Add(new ComboBoxPair("Equals", "Equals"));
            myControlEntity.ListOfKeyValuePairs = cbp1;
            myControlEntity.SelectedValue       = "Contains";
            myControlEntity.ID           = "cbxContainsEqual";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ToolTipx     = "";
            myControlEntity.DDLName      = "";
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string strSelectedDB = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            fileName = "DatabaseSelectedValue.txt";
            WriteValueToAppDirectoryFile(settingsDirectory, fileName, strSelectedDB);



            myActions.SetValueByKey("GwOptionSetupSelectedServer", strSelectedServer);
            myActions.SetValueByKey("GwOptionSetupSelectedDB", strSelectedDB);
            string strContainsEqual = myListControlEntity.Find(x => x.ID == "cbxContainsEqual").SelectedValue;



            //if (strSelectedDB != "TEST_HOSPIRA_1017" && strSelectedServer == ("cssql2014prod")) {
            //  myActions.MessageBoxShow("cssql2014prod was specified as the server, but TEST_HOSPIRA_1017 was not specified as the DB");
            //  goto DisplayWindow;
            //}



            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;

            int           intNumOfRecordsUnlocked = 0;
            SqlConnection con     = new SqlConnection("server=" + strSelectedServer + ";" + "Persist Security Info=True;User ID=" + strUserName + ";Password="******";database=" + strSelectedDB + "");
            string        sqlText = "";

            if (strContainsEqual == "Equals")
            {
                sqlText = "DECLARE @SearchStr nvarchar(100) " +
                          "SET @SearchStr = '" + mySearchTerm + "' " +
                          " " +
                          " " +
                          //"    -- Copyright � 2002 Narayana Vyas Kondreddi. All rights reserved. " +
                          //"    -- Purpose: To search all columns of all tables for a given search string " +
                          //"    -- Written by: Narayana Vyas Kondreddi " +
                          //"    -- Site: http://vyaskn.tripod.com " +
                          //"    -- Updated and tested by Tim Gaunt " +
                          //"    -- http://www.thesitedoctor.co.uk " +
                          //"    -- http://blogs.thesitedoctor.co.uk/tim/2010/02/19/Search+Every+Table+And+Field+In+A+SQL+Server+Database+Updated.aspx " +
                          //"    -- Tested on: SQL Server 7.0, SQL Server 2000, SQL Server 2005 and SQL Server 2010 " +
                          //"    -- Date modified: 03rd March 2011 19:00 GMT " +
                          "    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630)) " +
                          " " +
                          "    SET NOCOUNT ON " +
                          " " +
                          "    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110) " +
                          "    SET  @TableName = '' " +
                          "    SET @SearchStr2 = QUOTENAME(@SearchStr,'''') " +
                          " " +
                          "    WHILE @TableName IS NOT NULL " +
                          "     " +
                          "    BEGIN " +
                          "        SET @ColumnName = '' " +
                          "        SET @TableName =  " +
                          "        ( " +
                          "            SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)) " +
                          "            FROM     INFORMATION_SCHEMA.TABLES " +
                          "            WHERE         TABLE_TYPE = 'BASE TABLE' " +
                          "                AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName " +
                          "                AND    OBJECTPROPERTY( " +
                          "                        OBJECT_ID( " +
                          "                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) " +
                          "                             ), 'IsMSShipped' " +
                          "                               ) = 0 " +
                          "        ) " +
                          " " +
                          "        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL) " +
                          "             " +
                          "        BEGIN " +
                          "            SET @ColumnName = " +
                          "            ( " +
                          "                SELECT MIN(QUOTENAME(COLUMN_NAME)) " +
                          "                FROM     INFORMATION_SCHEMA.COLUMNS " +
                          "                WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2) " +
                          "                    AND    TABLE_NAME    = PARSENAME(@TableName, 1) " +
                          "                    AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal') " +
                          "                    AND    QUOTENAME(COLUMN_NAME) > @ColumnName " +
                          "            ) " +
                          "     " +
                          "            IF @ColumnName IS NOT NULL " +
                          "             " +
                          "            BEGIN " +
                          "                INSERT INTO #Results " +
                          "                EXEC " +
                          "                ( " +
                          "                    'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630) FROM ' + @TableName + ' (NOLOCK) ' + " +
                          "                    ' WHERE ' + @ColumnName + ' = ' + @SearchStr2 " +
                          "                ) " +
                          "            END " +
                          "        END     " +
                          "    END " +
                          " " +
                          "    SELECT '\"'  + ColumnName + '\"', '\"' + ColumnValue + '\"' FROM #Results " +
                          " " +
                          "DROP TABLE #Results ";
            }
            else
            {
                sqlText = "DECLARE @SearchStr nvarchar(100) " +
                          "SET @SearchStr = '" + mySearchTerm + "' " +
                          " " +
                          " " +
//"    -- Copyright � 2002 Narayana Vyas Kondreddi. All rights reserved. " +
//"    -- Purpose: To search all columns of all tables for a given search string " +
//"    -- Written by: Narayana Vyas Kondreddi " +
//"    -- Site: http://vyaskn.tripod.com " +
//"    -- Updated and tested by Tim Gaunt " +
//"    -- http://www.thesitedoctor.co.uk " +
//"    -- http://blogs.thesitedoctor.co.uk/tim/2010/02/19/Search+Every+Table+And+Field+In+A+SQL+Server+Database+Updated.aspx " +
//"    -- Tested on: SQL Server 7.0, SQL Server 2000, SQL Server 2005 and SQL Server 2010 " +
//"    -- Date modified: 03rd March 2011 19:00 GMT " +
                          "    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630)) " +
                          " " +
                          "    SET NOCOUNT ON " +
                          " " +
                          "    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110) " +
                          "    SET  @TableName = '' " +
                          "    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''') " +
                          " " +
                          "    WHILE @TableName IS NOT NULL " +
                          "     " +
                          "    BEGIN " +
                          "        SET @ColumnName = '' " +
                          "        SET @TableName =  " +
                          "        ( " +
                          "            SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)) " +
                          "            FROM     INFORMATION_SCHEMA.TABLES " +
                          "            WHERE         TABLE_TYPE = 'BASE TABLE' " +
                          "                AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName " +
                          "                AND    OBJECTPROPERTY( " +
                          "                        OBJECT_ID( " +
                          "                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) " +
                          "                             ), 'IsMSShipped' " +
                          "                               ) = 0 " +
                          "        ) " +
                          " " +
                          "        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL) " +
                          "             " +
                          "        BEGIN " +
                          "            SET @ColumnName = " +
                          "            ( " +
                          "                SELECT MIN(QUOTENAME(COLUMN_NAME)) " +
                          "                FROM     INFORMATION_SCHEMA.COLUMNS " +
                          "                WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2) " +
                          "                    AND    TABLE_NAME    = PARSENAME(@TableName, 1) " +
                          "                    AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal') " +
                          "                    AND    QUOTENAME(COLUMN_NAME) > @ColumnName " +
                          "            ) " +
                          "     " +
                          "            IF @ColumnName IS NOT NULL " +
                          "             " +
                          "            BEGIN " +
                          "                INSERT INTO #Results " +
                          "                EXEC " +
                          "                ( " +
                          "                    'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630) FROM ' + @TableName + ' (NOLOCK) ' + " +
                          "                    ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2 " +
                          "                ) " +
                          "            END " +
                          "        END     " +
                          "    END " +
                          " " +
                          "    SELECT '\"'  + ColumnName + '\"', '\"' + ColumnValue + '\"' FROM #Results " +
                          " " +
                          "DROP TABLE #Results ";
            }

            SqlCommand cmd = new SqlCommand(sqlText, con);

            cmd.CommandType = CommandType.Text;

            // Add Parameters to Command Parameters collection
            //cmd.Parameters.Add("@Value", SqlDbType.VarChar);
            //cmd.Parameters["@Value"].Value = mySearchTerm;

            StringBuilder sb         = new StringBuilder();
            int           intCount   = 0;
            string        strOutFile = @"C:\Data\FindDataInTable.csv";

            try {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile)) {
                    try {
                        con.Open();
                        cmd.CommandTimeout = 0;
                        SqlDataReader reader = cmd.ExecuteReader();
                        //(CommandBehavior.SingleRow)
                        while (reader.Read())
                        {
                            file.WriteLine(String.Format("{0},{1}", reader.GetString(0), reader.GetString(1).Replace("\"", "")));
                            intCount++;
                        }
                        reader.Close();
                    } finally {
                        con.Close();
                    }
                    file.WriteLine("Total Found:," + intCount.ToString());
                }
            } catch (Exception ex) {
                myActions.MessageBoxShow("Exception Message: " + ex.Message + " Exception InnerException: " + ex.InnerException);
            }

            string strExecutable = @"C:\Program Files\Microsoft Office\Office16\EXCEL.EXE";
            string strContent    = @"C:\Data\FindDataInTable.csv";

            myActions.MessageBoxShow("Launching Excel - hit okay and do not type until it loads");
            Process.Start(strExecutable, string.Concat("", strContent, ""));
            myActions.Sleep(3000);
            myActions.ActivateWindowByTitle("FindDataInTable.csv - Excel");
            myActions.TypeText("^({F10})", 1000);
            myActions.TypeText("%(H)", 1000);
            myActions.TypeText("O", 1000);
            myActions.TypeText("I", 1000);


myExit:
            Application.Current.Shutdown();
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("ExecuteWithBreakpointTrace"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(4000);
            // TODO: display dialog asking them which visual studio to activate
            // TODO: In IdealAutomateCore, create another PutAll override that does not ask if you want an alternative image when it cannot find image
            string            firstLine         = "";
            string            currentLine       = "";
            string            currentLineNumber = "";
            string            firstFileName     = "";
            string            currFileName      = "";
            string            firstLineNumber   = "";
            List <LineOfCode> listExecutedCode  = new List <LineOfCode>();

            myActions.TypeText("{F11}", 1000); // compile program and go to first breakpoint
            int intCtr = 0;

TryToFindYellowArrow:
            intCtr++;
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgYellowArrow.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgYellowArrow.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 1;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myImage.Tolerance = 60;

            int[,] myArray = myActions.PutAllDoNotCheckForAlternative(myImage);
            if (myArray.Length == 0 && intCtr < 50)
            {
                goto TryToFindYellowArrow;
            }
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of YellowArrow");
            }
            else
            {
                // myActions.MessageBoxShow("Found Yellow Arrow");
            }
            myActions.TypeText("^(c)", 200);
            currentLine = myActions.PutClipboardInEntity();
            firstLine   = currentLine;
            LineOfCode myLine = new LineOfCode();

            myLine.TextOfCode = currentLine;

            // get line number
            myActions.TypeText("^(g)", 200);
            myActions.TypeText("^(a)", 200);
            myActions.TypeText("^(c)", 200);
            currentLineNumber = myActions.PutClipboardInEntity();
            firstLineNumber   = currentLineNumber;
            myLine.LineNumber = currentLineNumber;
            myActions.TypeText("{ESCAPE}", 200);

            // get filename
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("a", 200);
            myActions.TypeText("^(c)", 200);
            currFileName    = myActions.PutClipboardInEntity();
            myLine.FileName = currFileName;
            firstFileName   = currFileName;
            myActions.TypeText("{ESCAPE}", 200);

            // add the line to list
            listExecutedCode.Add(myLine);

GetNextLine:
            // get next line
            myActions.TypeText("{F11}", 200); // next breakpoint

            // get line number
            myActions.TypeText("^(g)", 200);
            myActions.TypeText("^(a)", 200);
            myActions.TypeText("^(c)", 200);
            currentLineNumber = myActions.PutClipboardInEntity();
            firstLineNumber   = currentLineNumber;
            myLine.LineNumber = currentLineNumber;
            myActions.TypeText("{ESCAPE}", 200);

            // get filename
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("a", 200);
            myActions.TypeText("^(c)", 200);
            currFileName    = myActions.PutClipboardInEntity();
            myLine.FileName = currFileName;
            firstFileName   = currFileName;
            myActions.TypeText("{ESCAPE}", 200);

            // add the line to list
            listExecutedCode.Add(myLine);

            if (myLine.LineNumber != firstLineNumber)
            {
                goto GetNextLine;
            }

            myActions.MessageBoxShow("Successfully Reached End of Execution");

            string strOutFile = @"C:\Data\ExecutedCode.txt";

            if (File.Exists(strOutFile))
            {
                File.Delete(strOutFile);
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile)) {
                // Write list to text file so I can look at it
                foreach (LineOfCode item in listExecutedCode)
                {
                    file.WriteLine(item.FileName + " " + item.LineNumber + " " + item.TextOfCode);
                }
            }


            string strExecutable = @"C:\Windows\system32\notepad.exe";

            myActions.RunSync(strExecutable, strOutFile);


            // We found output completed and now want to copy the results
            // to notepad

            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            if (myWebSite == "http://www.google.com")
            {
                myActions.TypeText("%(d)", 500);
                myActions.TypeText("{ESC}", 500);
                myActions.TypeText("{F6}", 500);
                myActions.TypeText("{TAB}", 500);
                myActions.TypeText("{TAB 2}", 500);
                myActions.TypeText("{ESC}", 500);
            }
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);

            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            myActions.Run(@"C:\Program Files\Microsoft Office\Office15\EXCEL.EXE", @"C:\SVNStats\SVNStats.xlsx");
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 6
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;


            bool      _mouseUp = false;
            MouseHook mh;
            var       window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();

            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("SnippingToolAutomation"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            int intTop  = (int)SystemParameters.WorkArea.Height - 200;
            int intLeft = (int)SystemParameters.WorkArea.Width - 200;

            myActions.SetValueByKeyGlobal("WindowTop", "-1");
            myActions.SetValueByKeyGlobal("WindowLeft", "-1");
snipDialog:

            myActions.Sleep(1000);
            myActions.Run(@"C:\WINDOWS\system32\SnippingTool.exe", "");
            myActions.Sleep(1000);
            myActions.TypeText("%(n)", 1000);
            myActions.TypeText("{ESC}", 1000);
            myActions.TypeText("%(\" \")n", 1000);


            int                  intRowCtr           = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnSnipWithComments";
            myControlEntity.Text         = "Snip w/ Comments";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnSnip";
            myControlEntity.Text         = "Snip";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnExit";
            myControlEntity.Text         = "Exit";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            int intSavedTop  = myActions.GetValueByKeyAsIntGlobal("WindowTop");
            int intSavedLeft = myActions.GetValueByKeyAsIntGlobal("WindowLeft");

            if (intSavedTop > 0)
            {
                intTop = intSavedTop;
            }
            if (intSavedLeft > 0)
            {
                intLeft = intSavedLeft;
            }
            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 200, 200, intTop, intLeft);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }
            if (strButtonPressed == "btnExit")
            {
                // myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            bool snipWithComments = false;

            if (strButtonPressed == "btnSnipWithComments")
            {
                snipWithComments = true;
            }
            //SnippingTool.Snip();

            //if (SnippingTool.Image != null) {
            //    Clipboard.SetImage(BitmapSourceFromImage(SnippingTool.Image));
            //}
            myActions.TypeText("^({PRTSC})", 1000);


            myActions.SetValueByKey("Mouseup", "false");
            //mh = new MouseHook();
            //mh.Install();
            intRowCtr           = 0;
            myControlEntity     = new ControlEntity();
            myListControlEntity = new List <ControlEntity>();
            cbp = new List <ComboBoxPair>();

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnDoneSnipping";
            myControlEntity.Text         = "Done Snipping";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnAddComments";
            myControlEntity.Text         = "Add Comments";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnExit";
            myControlEntity.Text         = "Exit";
            myControlEntity.ColumnSpan   = 0;
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            intSavedTop  = myActions.GetValueByKeyAsIntGlobal("WindowTop");
            intSavedLeft = myActions.GetValueByKeyAsIntGlobal("WindowLeft");
            if (intSavedTop > 0)
            {
                intTop = intSavedTop;
            }
            if (intSavedLeft > 0)
            {
                intLeft = intSavedLeft;
            }
            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 200, 200, intTop, intLeft);
            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }
            if (strButtonPressed == "btnExit")
            {
                // myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            if (strButtonPressed == "btnAddComments")
            {
                snipWithComments = true;
            }

            myActions.ActivateWindowByTitle("Snipping Tool");
            myActions.TypeText("^(c)", 500);
            //mh.MouseMove += new MouseHook.MouseHookCallback(mouseHook_MouseMove);
            string mouseUp = "false";
            //mouseWatcher = eventHookFactory.GetMouseWatcher();
            //mouseWatcher.Start();
            //mouseWatcher.OnMouseInput += (s, e) => {
            //    if (e.Message.ToString() == "WM_LBUTTONUP") {
            //        myActions.SetValueByKey("MouseUp", "true");
            //    }
            //};
            //while (mouseUp == "false") {
            //    myActions.TypeText("^(c)", 500);
            //    mouseUp = myActions.GetValueByKey("MouseUp");

            // //   myActions.Sleep(5000);
            //}
            string strComments = "";

            if (snipWithComments)
            {
                intRowCtr           = 0;
                myControlEntity     = new ControlEntity();
                myListControlEntity = new List <ControlEntity>();
                cbp = new List <ComboBoxPair>();
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Heading;
                myControlEntity.ID           = "lbl";
                myControlEntity.Text         = "Comments";
                myControlEntity.RowNumber    = intRowCtr;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                intRowCtr++;
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblComments";
                myControlEntity.Text         = "Comments";
                myControlEntity.RowNumber    = intRowCtr;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.TextBox;
                myControlEntity.ID           = "txtComments";
                myControlEntity.Text         = ""; //myActions.GetValueByKey("Comments"); ;
                myControlEntity.ToolTipx     = "";
                myControlEntity.RowNumber    = intRowCtr;
                myControlEntity.Width        = 800;
                myControlEntity.Height       = 300;
                myControlEntity.TextWrap     = true;
                myControlEntity.Multiline    = true;
                myControlEntity.ColumnNumber = 1;
                myControlEntity.ColumnSpan   = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 800, 0, 0);
                if (strButtonPressed == "btnCancel")
                {
                    myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                    goto myExit;
                }

                strComments = myListControlEntity.Find(x => x.ID == "txtComments").Text;
                myActions.SetValueByKey("Comments", strComments);
            }
            myActions.TypeText("^(c)", 500);
            myActions.TypeText("%(\" \")n", 1000);
            List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("wordpad");

            myWindowTitles.RemoveAll(item => item == "");
            if (myWindowTitles.Count > 0)
            {
                myActions.ActivateWindowByTitle(myWindowTitles[0]);
                if (strComments != "")
                {
                    myActions.TypeText(strComments, 1000);
                }
                myActions.TypeText("^(v)", 1000);
                myActions.TypeText("{ENTER}", 1000);
            }
            myActions.TypeText("%(\" \")n", 500);
            myActions.TypeText(" ", 1000);
            goto snipDialog;
            myActions.TypeText("^({PRTSC})", 1000);
            myActions.MessageBoxShow("click okay to continue");
            myActions.TypeText("^(c)", 500);



            myActions.TypeText("^(c)", 500);
            myActions.TypeText("%(\" \")n", 1000);

            myActions.Sleep(15000);
            goto myExit;
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();

            System.Windows.Application.Current.Shutdown();
        }
Ejemplo n.º 7
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            string strSavedDomainName = myActions.GetValueByKey("DomainName");

            if (strSavedDomainName == "")
            {
                strSavedDomainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
            }
            InitializeComponent();
            this.Hide();


            listHotKeyRecords = new List <HotKeyRecord>();

            HotKeyRecord myHotKeyRecord = new HotKeyRecord();
            string       strHotKey      = "Ctrl+Alt+N";

            myHotKeyRecord.HotKeys        = strHotKey.Split('+');
            myHotKeyRecord.Executable     = @"OpenLineInNotepad";
            myHotKeyRecord.ExecuteContent = null;
            myHotKeyRecord.ScriptID       = 0;
            bool boolHotKeysGood = true;

            foreach (string myHotKey in myHotKeyRecord.HotKeys)
            {
                if (dictVirtualKeyCodes.ContainsKey(myHotKey))
                {
                    MessageBox.Show("Invalid hotkey: " + myHotKey);
                    boolHotKeysGood = false;
                }
            }
            if (boolHotKeysGood)
            {
                listHotKeyRecords.Add(myHotKeyRecord);
            }

            dictVirtualKeyCodes.Add("Ctrl", VirtualKeyCode.CONTROL);
            dictVirtualKeyCodes.Add("Alt", VirtualKeyCode.MENU);
            dictVirtualKeyCodes.Add("Shift", VirtualKeyCode.SHIFT);
            dictVirtualKeyCodes.Add("Space", VirtualKeyCode.SPACE);
            dictVirtualKeyCodes.Add("Up", VirtualKeyCode.UP);
            dictVirtualKeyCodes.Add("Down", VirtualKeyCode.DOWN);
            dictVirtualKeyCodes.Add("Left", VirtualKeyCode.LEFT);
            dictVirtualKeyCodes.Add("Right", VirtualKeyCode.RIGHT);
            dictVirtualKeyCodes.Add("A", VirtualKeyCode.VK_A);
            dictVirtualKeyCodes.Add("B", VirtualKeyCode.VK_B);
            dictVirtualKeyCodes.Add("C", VirtualKeyCode.VK_C);
            dictVirtualKeyCodes.Add("D", VirtualKeyCode.VK_D);
            dictVirtualKeyCodes.Add("E", VirtualKeyCode.VK_E);
            dictVirtualKeyCodes.Add("F", VirtualKeyCode.VK_F);
            dictVirtualKeyCodes.Add("G", VirtualKeyCode.VK_G);
            dictVirtualKeyCodes.Add("H", VirtualKeyCode.VK_H);
            dictVirtualKeyCodes.Add("I", VirtualKeyCode.VK_I);
            dictVirtualKeyCodes.Add("J", VirtualKeyCode.VK_J);
            dictVirtualKeyCodes.Add("K", VirtualKeyCode.VK_K);
            dictVirtualKeyCodes.Add("L", VirtualKeyCode.VK_L);
            dictVirtualKeyCodes.Add("M", VirtualKeyCode.VK_M);
            dictVirtualKeyCodes.Add("N", VirtualKeyCode.VK_N);
            dictVirtualKeyCodes.Add("O", VirtualKeyCode.VK_O);
            dictVirtualKeyCodes.Add("P", VirtualKeyCode.VK_P);
            dictVirtualKeyCodes.Add("Q", VirtualKeyCode.VK_Q);
            dictVirtualKeyCodes.Add("R", VirtualKeyCode.VK_R);
            dictVirtualKeyCodes.Add("S", VirtualKeyCode.VK_S);
            dictVirtualKeyCodes.Add("T", VirtualKeyCode.VK_T);
            dictVirtualKeyCodes.Add("U", VirtualKeyCode.VK_U);
            dictVirtualKeyCodes.Add("V", VirtualKeyCode.VK_V);
            dictVirtualKeyCodes.Add("W", VirtualKeyCode.VK_W);
            dictVirtualKeyCodes.Add("X", VirtualKeyCode.VK_X);
            dictVirtualKeyCodes.Add("Y", VirtualKeyCode.VK_Y);
            dictVirtualKeyCodes.Add("Z", VirtualKeyCode.VK_Z);
            // Create a timer and set a two millisecond interval.
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Interval = 2;

            // Alternate method: create a Timer with an interval argument to the constructor.
            //aTimer = new System.Timers.Timer(2000);

            // Create a timer with a two millisecond interval.
            aTimer = new System.Timers.Timer(2);

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed += OnTimedEvent;

            // Have the timer fire repeated events (true is the default)
            aTimer.AutoReset = true;

            // Start the timer
            aTimer.Enabled = true;
DisplayFindTextInFilesWindow:
            int intRowCtr = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp2 = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp3 = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lbl";
            myControlEntity.Text         = "Find Text In Files";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFindWhat";
            myControlEntity.Text         = "FindWhat";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 150;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType   = ControlType.ComboBox;
            myControlEntity.SelectedValue = myActions.GetValueByKey("cbxFindWhatSelectedValue");
            myControlEntity.ID            = "cbxFindWhat";
            myControlEntity.RowNumber     = intRowCtr;
            myControlEntity.ToolTipx      = "";
            //foreach (var item in alcbxFindWhat) {
            //    cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
            //}
            //myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;

            myControlEntity.ColumnSpan = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFileType";
            myControlEntity.Text         = "FileType";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 150;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType   = ControlType.ComboBox;
            myControlEntity.SelectedValue = myActions.GetValueByKey("cbxFileTypeSelectedValue");
            myControlEntity.ID            = "cbxFileType";
            myControlEntity.RowNumber     = intRowCtr;
            myControlEntity.ToolTipx      = "Here is an example: *.*";
            //foreach (var item in alcbxFileType) {
            //    cbp1.Add(new ComboBoxPair(item.ToString(), item.ToString()));
            //}
            //myControlEntity.ListOfKeyValuePairs = cbp1;
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;
            myControlEntity.ColumnSpan         = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblExclude";
            myControlEntity.Text         = "Exclude";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType        = ControlType.ComboBox;
            myControlEntity.SelectedValue      = myActions.GetValueByKey("cbxExcludeSelectedValue");
            myControlEntity.ID                 = "cbxExclude";
            myControlEntity.RowNumber          = intRowCtr;
            myControlEntity.ToolTipx           = "Here is an example: *.dll;*.exe;*.png;*.xml;*.cache;*.sln;*.suo;*.pdb;*.csproj;*.deploy";
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;
            myControlEntity.ColumnSpan         = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFolder";
            myControlEntity.Text         = "Folder";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType        = ControlType.ComboBox;
            myControlEntity.SelectedValue      = myActions.GetValueByKey("cbxFolderSelectedValue");
            myControlEntity.ID                 = "cbxFolder";
            myControlEntity.RowNumber          = intRowCtr;
            myControlEntity.ToolTipx           = @"Here is an example: C:\Users\harve\Documents\GitHub";
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;
            myControlEntity.ColumnSpan         = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnSelectFolder";
            myControlEntity.Text         = "Select Folder...";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 3;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "chkMatchCase";
            myControlEntity.Text         = "Match Case";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            string strMatchCase = myActions.GetValueByKey("chkMatchCase");

            if (strMatchCase.ToLower() == "true")
            {
                myControlEntity.Checked = true;
            }
            else
            {
                myControlEntity.Checked = false;
            }
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "chkUseRegularExpression";
            myControlEntity.Text         = "UseRegularExpression";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            string strUseRegularExpression = myActions.GetValueByKey("chkUseRegularExpression");

            if (strUseRegularExpression.ToLower() == "true")
            {
                myControlEntity.Checked = true;
            }
            else
            {
                myControlEntity.Checked = false;
            }
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

DisplayWindowAgain:
            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 1200, 100, 100);

LineAfterDisplayWindow:
            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            boolMatchCase            = myListControlEntity.Find(x => x.ID == "chkMatchCase").Checked;
            boolUseRegularExpression = myListControlEntity.Find(x => x.ID == "chkUseRegularExpression").Checked;

            strFindWhat = myListControlEntity.Find(x => x.ID == "cbxFindWhat").SelectedValue;
            //  string strFindWhatKey = myListControlEntity.Find(x => x.ID == "cbxFindWhat").SelectedKey;

            string strFileType = myListControlEntity.Find(x => x.ID == "cbxFileType").SelectedValue;
            //     string strFileTypeKey = myListControlEntity.Find(x => x.ID == "cbxFileType").SelectedKey;

            string strExclude = myListControlEntity.Find(x => x.ID == "cbxExclude").SelectedValue;
            //      string strExcludeKey = myListControlEntity.Find(x => x.ID == "cbxExclude").SelectedKey;

            string strFolder = myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedValue;

            //     string strFolderKey = myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedKey;
            myActions.SetValueByKey("chkMatchCase", boolMatchCase.ToString());
            myActions.SetValueByKey("chkUseRegularExpression", boolUseRegularExpression.ToString());
            myActions.SetValueByKey("cbxFindWhatSelectedValue", strFindWhat);
            myActions.SetValueByKey("cbxFileTypeSelectedValue", strFileType);
            myActions.SetValueByKey("cbxExcludeSelectedValue", strExclude);
            myActions.SetValueByKey("cbxFolderSelectedValue", strFolder);
            string settingsDirectory = "";

            if (strButtonPressed == "btnSelectFolder")
            {
                var dialog = new System.Windows.Forms.FolderBrowserDialog();
                dialog.SelectedPath = myActions.GetValueByKey("LastSearchFolder");
                string str = "LastSearchFolder";


                System.Windows.Forms.DialogResult result = dialog.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK && Directory.Exists(dialog.SelectedPath))
                {
                    myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedValue = dialog.SelectedPath;
                    myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedKey   = dialog.SelectedPath;
                    myListControlEntity.Find(x => x.ID == "cbxFolder").Text          = dialog.SelectedPath;
                    myActions.SetValueByKey("LastSearchFolder", dialog.SelectedPath);
                    strFolder = dialog.SelectedPath;
                    myActions.SetValueByKey("cbxFolderSelectedValue", strFolder);
                    string strScriptName          = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
                    string fileName               = "cbxFolder.txt";
                    string strApplicationBinDebug = System.Windows.Forms.Application.StartupPath;
                    string myNewProjectSourcePath = strApplicationBinDebug.Replace("\\bin\\Debug", "");
                    settingsDirectory = GetAppDirectoryForScript(myActions.ConvertFullFileNameToScriptPath(myNewProjectSourcePath));
                    string    settingsPath = System.IO.Path.Combine(settingsDirectory, fileName);
                    ArrayList alHosts      = new ArrayList();
                    cbp = new List <ComboBoxPair>();
                    cbp.Clear();
                    cbp.Add(new ComboBoxPair("--Select Item ---", "--Select Item ---"));
                    ComboBox myComboBox = new ComboBox();


                    if (!File.Exists(settingsPath))
                    {
                        using (StreamWriter objSWFile = File.CreateText(settingsPath)) {
                            objSWFile.Close();
                        }
                    }
                    using (StreamReader objSRFile = File.OpenText(settingsPath)) {
                        string strReadLine = "";
                        while ((strReadLine = objSRFile.ReadLine()) != null)
                        {
                            string[] keyvalue = strReadLine.Split('^');
                            if (keyvalue[0] != "--Select Item ---")
                            {
                                cbp.Add(new ComboBoxPair(keyvalue[0], keyvalue[1]));
                            }
                        }
                        objSRFile.Close();
                    }
                    string strNewHostName          = dialog.SelectedPath;
                    List <ComboBoxPair> alHostx    = cbp;
                    List <ComboBoxPair> alHostsNew = new List <ComboBoxPair>();
                    ComboBoxPair        myCbp      = new ComboBoxPair(strNewHostName, strNewHostName);
                    bool boolNewItem = false;

                    alHostsNew.Add(myCbp);
                    if (alHostx.Count > 14)
                    {
                        for (int i = alHostx.Count - 1; i > 0; i--)
                        {
                            if (alHostx[i]._Key.Trim() != "--Select Item ---")
                            {
                                alHostx.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    foreach (ComboBoxPair item in alHostx)
                    {
                        if (strNewHostName != item._Key && item._Key != "--Select Item ---")
                        {
                            boolNewItem = true;
                            alHostsNew.Add(item);
                        }
                    }

                    using (StreamWriter objSWFile = File.CreateText(settingsPath)) {
                        foreach (ComboBoxPair item in alHostsNew)
                        {
                            if (item._Key != "")
                            {
                                objSWFile.WriteLine(item._Key + '^' + item._Value);
                            }
                        }
                        objSWFile.Close();
                    }
                    goto DisplayWindowAgain;
                }
            }
            string strFindWhatToUse = "";
            string strFileTypeToUse = "";
            string strExcludeToUse  = "";
            string strFolderToUse   = "";

            if (strButtonPressed == "btnOkay")
            {
                if ((strFindWhat == "--Select Item ---" || strFindWhat == ""))
                {
                    myActions.MessageBoxShow("Please enter Find What or select Find What from ComboBox; else press Cancel to Exit");
                    goto DisplayFindTextInFilesWindow;
                }
                if ((strFileType == "--Select Item ---" || strFileType == ""))
                {
                    myActions.MessageBoxShow("Please enter File Type or select File Type from ComboBox; else press Cancel to Exit");
                    goto DisplayFindTextInFilesWindow;
                }
                if ((strExclude == "--Select Item ---" || strExclude == ""))
                {
                    myActions.MessageBoxShow("Please enter Exclude or select Exclude from ComboBox; else press Cancel to Exit");
                    goto DisplayFindTextInFilesWindow;
                }
                if ((strFolder == "--Select Item ---" || strFolder == ""))
                {
                    myActions.MessageBoxShow("Please enter Folder or select Folder from ComboBox; else press Cancel to Exit");
                    goto DisplayFindTextInFilesWindow;
                }



                strFindWhatToUse = strFindWhat;

                if (boolUseRegularExpression)
                {
                    strFindWhatToUse = strFindWhatToUse.Replace(")", "\\)").Replace("(", "\\(");
                }


                strFileTypeToUse = strFileType;



                strExcludeToUse = strExclude;


                strFolderToUse = strFolder;
            }


            strPathToSearch = strFolderToUse;

            strSearchPattern = strFileTypeToUse;

            strSearchExcludePattern = strExcludeToUse;

            strSearchText = strFindWhatToUse;

            strLowerCaseSearchText = strFindWhatToUse.ToLower();
            myActions.SetValueByKey("FindWhatToUse", strFindWhatToUse);

            System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
            st.Start();
            intHits = 0;
            int             intLineCtr;
            List <FileInfo> myFileList = TraverseTree(strSearchPattern, strPathToSearch);
            int             intFiles   = 0;

            matchInfoList = new List <MatchInfo>();
            //         myFileList = myFileList.OrderBy(fi => fi.FullName).ToList();
            Parallel.ForEach(myFileList, myFileInfo => {
                intLineCtr            = 0;
                boolStringFoundInFile = false;
                ReadFileToString(myFileInfo.FullName, intLineCtr, matchInfoList);
                if (boolStringFoundInFile)
                {
                    intFiles++;
                }
            });
            matchInfoList = matchInfoList.Where(mi => mi != null).OrderBy(mi => mi.FullName).ThenBy(mi => mi.LineNumber).ToList();
            List <string> lines = new List <string>();

            foreach (var item in matchInfoList)
            {
                lines.Add("\"" + item.FullName + "\"(" + item.LineNumber + "," + item.LinePosition + "): " + item.LineText.Length.ToString() + " " + item.LineText.Substring(0, item.LineText.Length > 5000 ? 5000 : item.LineText.Length));
            }


            string strApplicationBinDebug1 = System.Windows.Forms.Application.StartupPath;
            string myNewProjectSourcePath1 = strApplicationBinDebug1.Replace("\\bin\\Debug", "");

            settingsDirectory = GetAppDirectoryForScript(myActions.ConvertFullFileNameToScriptPath(myNewProjectSourcePath1));
            using (FileStream fs = new FileStream(settingsDirectory + @"\MatchInfo.txt", FileMode.Create)) {
                StreamWriter file = new System.IO.StreamWriter(fs, Encoding.Default);

                file.WriteLine(@"-- " + strSearchText + " in " + strPathToSearch + " from " + strSearchPattern + " excl  " + strSearchExcludePattern + " --");
                foreach (var item in matchInfoList)
                {
                    file.WriteLine("\"" + item.FullName + "\"(" + item.LineNumber + "," + item.LinePosition + "): " + item.LineText.Substring(0, item.LineText.Length > 5000 ? 5000 : item.LineText.Length));
                }
                int intUniqueFiles = matchInfoList.Select(x => x.FullName).Distinct().Count();
                st.Stop();
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = st.Elapsed;
                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                   ts.Hours, ts.Minutes, ts.Seconds,
                                                   ts.Milliseconds / 10);
                file.WriteLine("RunTime " + elapsedTime);
                file.WriteLine(intHits.ToString() + " hits");
                // file.WriteLine(myFileList.Count().ToString() + " files");
                file.WriteLine(intUniqueFiles.ToString() + " files with hits");
                file.Close();


                // Get the elapsed time as a TimeSpan value.
                ts = st.Elapsed;
                // Format and display the TimeSpan value.
                elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
                Console.WriteLine("RunTime " + elapsedTime);
                Console.WriteLine(intHits.ToString() + " hits");
                // Console.WriteLine(myFileList.Count().ToString() + " files");
                Console.WriteLine(intUniqueFiles.ToString() + " files with hits");
                Console.ReadLine();
                string strExecutable = @"C:\Program Files (x86)\Notepad++\notepad++.exe";
                string strContent    = settingsDirectory + @"\MatchInfo.txt";
                Process.Start(strExecutable, string.Concat("", strContent, ""));
                myActions.ScriptEndedSuccessfullyUpdateStats();
                myActions.MessageBoxShow("RunTime: " + elapsedTime + "\n\r\n\rHits: " + intHits.ToString() + "\n\r\n\rFiles with hits: " + intUniqueFiles.ToString() + "\n\r\n\rPut Cursor on line and\n\r press Ctrl+Alt+N\n\rto view detail page. ");
            }


            if (strButtonPressed == "btnOkay")
            {
                strButtonPressed = myActions.WindowMultipleControlsMinimized(ref myListControlEntity, 300, 1200, 100, 100);
                myActions.ScriptStartedUpdateStats();
                goto LineAfterDisplayWindow;
            }


myExit:
            int myExecCount = myActions.GetValueByKeyAsInt("ScriptTotalExecutions");

            myExecCount--;
            myActions.SetValueByKey("ScriptTotalExecutions", myExecCount.ToString());
            Application.Current.Shutdown();
        }
Ejemplo n.º 8
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("DebugTrace"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            //string directory = AppDomain.CurrentDomain.BaseDirectory;
            //directory = directory.Replace("\\bin\\Debug\\", "");
            //int intLastSlashIndex = directory.LastIndexOf("\\");
            //directory = directory.Substring(0, intLastSlashIndex);
            //  string strScriptName = directory.Substring(intLastSlashIndex + 1);
            // string strScriptName = System.Reflection.Assembly.GetCallingAssembly().GetName().Name;
            string settingsDirectory =
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\IdealAutomate\\";

            if (!Directory.Exists(settingsDirectory))
            {
                Directory.CreateDirectory(settingsDirectory);
            }
            string filePath       = Path.Combine(settingsDirectory, "TraceLog.txt");
            string filePath2      = Path.Combine(settingsDirectory, "TempCode.txt");
            string strOutFile     = filePath;
            string strOutFile2    = filePath2;
            int    intCurrentLine = 0;

            if (File.Exists(strOutFile))
            {
                File.Delete(strOutFile);
            }

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Debug Trace";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Variable of Interest";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtVariableOfInterest";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select F10/F11";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "cbxDepth";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("F10 - Step Over", "F10"));
            cbp.Add(new ComboBoxPair("F11 - Step Into", "F11"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "F11";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Stop at variable";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            string myVariableOfInterest = myListControlEntity.Find(x => x.ID == "txtVariableOfInterest").Text;
            string myDepth = myListControlEntity.Find(x => x.ID == "cbxDepth").SelectedValue;

            bool boolStopAtVariable = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;


            myActions.Sleep(1000);
            string strCurrentLine = "";

            string[]      myCodeArray        = new string[10000];
            string        strPrevLine1       = "";
            string        strPrevLine2       = "";
            string        strPrevLine3       = "";
            string        strCurrentFile     = "";
            string        strCurrentFileText = "";
            string        strPrevFile        = "";
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 9000; i++)
            {
                myActions.TypeText("{F11}", 500);
                myActions.TypeText("^(c)", 500);
                strCurrentLine = myActions.PutClipboardInEntity();
                strCurrentLine = strCurrentFile + " " + intCurrentLine.ToString() + " " + strCurrentLine;
                if (strCurrentLine == strPrevLine1 && strPrevLine1 == strPrevLine2 && strPrevLine2 == strPrevLine3)
                {
                    break;
                }
                strPrevLine3 = strPrevLine2;
                strPrevLine2 = strPrevLine1;
                strPrevLine1 = strCurrentLine;

                if (strCurrentLine != "")
                {
                    WriteALine(strCurrentLine);
                }
                if (strCurrentLine.Contains("tmpParamValue= HTMLEncode(Request.Form(strParamName))"))
                {
                    myActions.TypeText("^(d)", 100);
                    myActions.TypeText("^(l)", 100);
                    myActions.TypeText("^(a)", 100);
                    myActions.TypeText("^(c)", 100);
                    string strLocals = myActions.PutClipboardInEntity();
                    WriteALine(strLocals);
                }
            }



            string strExecutable = @"C:\Windows\system32\notepad.exe";
            string strContent    = strOutFile;

            Process.Start(strExecutable, string.Concat("", strContent, ""));
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 9
0
        private void searchDialogRtn()
        {
            listCategoryMethod.Clear();
            intCol                    = 0;
            intRow                    = 0;
            intStartPageMethod        = 0;
            intEndPageMethod          = 0;
            intTotalMethods           = 0;
            intPageSize               = 75;
            intColumnWidth            = 250;
            strPreviousCategory       = "";
            strApplicationBinDebug    = "";
            myNewProjectSourcePath    = "";
            strPathToSearch           = @"C:\SVNIA\trunk";
            strSearchPattern          = @"*.*";
            strSearchExcludePattern   = @"";
            strSearchText             = @"notepad";
            strLowerCaseSearchText    = @"notepad";
            intHits                   = 0;
            _boolMatchCase            = false;
            _boolUseRegularExpression = false;
            _boolStringFoundInFile    = false;
            strFindWhat               = "";
            //
            string strApplicationBinDebug1 = System.Windows.Forms.Application.StartupPath;
            string myNewProjectSourcePath1 = strApplicationBinDebug1.Replace("\\bin\\Debug", "");

            System.IO.DirectoryInfo di = new DirectoryInfo(Path.Combine(myNewProjectSourcePath1, @"Text"));

DisplaySelectFolderWindow:
            int intRowCtr = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp2 = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp3 = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lbl";
            myControlEntity.Text         = "Find Text In Files";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblHotkeysOnly";
            myControlEntity.Text         = "HotkeysOnly";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 150;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("Hotkeys", "Hotkeys"));
            cbp.Add(new ComboBoxPair("All Executables", "All Executables"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = myControlEntity.SelectedValue = myActions.GetValueByKey("cbxHotkeysOnlySelectedValue");
            if (myControlEntity.SelectedValue == null || myControlEntity.SelectedValue == "")
            {
                myControlEntity.SelectedValue = "--Select Item ---";
            }
            myControlEntity.ID           = "cbxHotkeysOnly";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblExecuteCategorize";
            myControlEntity.Text         = "ExecuteCategorize";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 150;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp1.Clear();
            cbp1.Add(new ComboBoxPair("Execute", "Execute"));
            cbp1.Add(new ComboBoxPair("Categorize", "Categorize"));
            myControlEntity.ListOfKeyValuePairs = cbp1;
            myControlEntity.SelectedValue       = myControlEntity.SelectedValue = myActions.GetValueByKey("cbxExecuteCategorizeSelectedValue");
            if (myControlEntity.SelectedValue == null || myControlEntity.SelectedValue == "")
            {
                myControlEntity.SelectedValue = "--Select Item ---";
            }
            myControlEntity.ID           = "cbxExecuteCategorize";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFindWhat";
            myControlEntity.Text         = "FindWhat";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 150;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType   = ControlType.ComboBox;
            myControlEntity.SelectedValue = myActions.GetValueByKey("cbxFindWhatSelectedValue");
            myControlEntity.ID            = "cbxFindWhat";
            myControlEntity.RowNumber     = intRowCtr;
            myControlEntity.ToolTipx      = "";
            //foreach (var item in alcbxFindWhat) {
            //    cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
            //}
            //myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;

            myControlEntity.ColumnSpan = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFolder";
            myControlEntity.Text         = "Folder";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType        = ControlType.ComboBox;
            myControlEntity.SelectedValue      = myActions.GetValueByKey("cbxFolderSelectedValue");
            myControlEntity.ID                 = "cbxFolder";
            myControlEntity.RowNumber          = intRowCtr;
            myControlEntity.ToolTipx           = @"Here is an example: C:\Users\harve\Documents\GitHub";
            myControlEntity.ComboBoxIsEditable = true;
            myControlEntity.ColumnNumber       = 1;
            myControlEntity.ColumnSpan         = 2;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnSelectFolder";
            myControlEntity.Text         = "Select Folder...";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 3;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "chkMatchCase";
            myControlEntity.Text         = "Match Case";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            string strMatchCase = myActions.GetValueByKey("chkMatchCase");

            if (strMatchCase.ToLower() == "true")
            {
                myControlEntity.Checked = true;
            }
            else
            {
                myControlEntity.Checked = false;
            }
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "chkUseRegularExpression";
            myControlEntity.Text         = "UseRegularExpression";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            string strUseRegularExpression = myActions.GetValueByKey("chkUseRegularExpression");

            if (strUseRegularExpression.ToLower() == "true")
            {
                myControlEntity.Checked = true;
            }
            else
            {
                myControlEntity.Checked = false;
            }
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


DisplaySelectFolderWindowAgain:
            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 1200, 100, 100);
LineAfterDisplayWindow:
            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                return;
            }

            _boolMatchCase            = myListControlEntity.Find(x => x.ID == "chkMatchCase").Checked;
            _boolUseRegularExpression = myListControlEntity.Find(x => x.ID == "chkUseRegularExpression").Checked;
            strHotkeysOnly            = myListControlEntity.Find(x => x.ID == "cbxHotkeysOnly").SelectedValue;
            strExecuteCategorize      = myListControlEntity.Find(x => x.ID == "cbxExecuteCategorize").SelectedValue;
            myActions.SetValueByKey("cbxHotkeysOnlySelectedValue", strHotkeysOnly);
            myActions.SetValueByKey("cbxExecuteCategorizeSelectedValue", strExecuteCategorize);
            strFindWhat = myListControlEntity.Find(x => x.ID == "cbxFindWhat").SelectedValue;
            //  string strFindWhatKey = myListControlEntity.Find(x => x.ID == "cbxFindWhat").SelectedKey;


            strFolder = myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedValue;
            //     string strFolderKey = myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedKey;
            myActions.SetValueByKey("chkMatchCase", _boolMatchCase.ToString());
            myActions.SetValueByKey("chkUseRegularExpression", _boolUseRegularExpression.ToString());
            myActions.SetValueByKey("cbxFindWhatSelectedValue", strFindWhat);
            myActions.SetValueByKey("cbxFolderSelectedValue", strFolder);
            string settingsDirectory = "";

            if (strButtonPressed == "btnSelectFolder")
            {
                var dialog = new System.Windows.Forms.FolderBrowserDialog();
                dialog.SelectedPath = myActions.GetValueByKey("LastSearchFolder");
                string str = "LastSearchFolder";


                System.Windows.Forms.DialogResult result = dialog.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK && Directory.Exists(dialog.SelectedPath))
                {
                    myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedValue = dialog.SelectedPath;
                    myListControlEntity.Find(x => x.ID == "cbxFolder").SelectedKey   = dialog.SelectedPath;
                    myListControlEntity.Find(x => x.ID == "cbxFolder").Text          = dialog.SelectedPath;
                    myActions.SetValueByKey("LastSearchFolder", dialog.SelectedPath);
                    strFolder = dialog.SelectedPath;
                    myActions.SetValueByKey("cbxFolderSelectedValue", strFolder);
                    string strScriptName          = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
                    string fileName               = "cbxFolder.txt";
                    string strApplicationBinDebug = System.Windows.Forms.Application.StartupPath;
                    string myNewProjectSourcePath = strApplicationBinDebug.Replace("\\bin\\Debug", "");
                    settingsDirectory = GetAppDirectoryForScript(myActions.ConvertFullFileNameToScriptPath(myNewProjectSourcePath));
                    string    settingsPath = System.IO.Path.Combine(settingsDirectory, fileName);
                    ArrayList alHosts      = new ArrayList();
                    cbp = new List <ComboBoxPair>();
                    cbp.Clear();
                    cbp.Add(new ComboBoxPair("--Select Item ---", "--Select Item ---"));
                    ComboBox myComboBox = new ComboBox();


                    if (!File.Exists(settingsPath))
                    {
                        using (StreamWriter objSWFile = File.CreateText(settingsPath)) {
                            objSWFile.Close();
                        }
                    }
                    using (StreamReader objSRFile = File.OpenText(settingsPath)) {
                        string strReadLine = "";
                        while ((strReadLine = objSRFile.ReadLine()) != null)
                        {
                            string[] keyvalue = strReadLine.Split('^');
                            if (keyvalue[0] != "--Select Item ---")
                            {
                                cbp.Add(new ComboBoxPair(keyvalue[0], keyvalue[1]));
                            }
                        }
                        objSRFile.Close();
                    }
                    string strNewHostName          = dialog.SelectedPath;
                    List <ComboBoxPair> alHostx    = cbp;
                    List <ComboBoxPair> alHostsNew = new List <ComboBoxPair>();
                    ComboBoxPair        myCbp      = new ComboBoxPair(strNewHostName, strNewHostName);
                    bool boolNewItem = false;

                    alHostsNew.Add(myCbp);
                    if (alHostx.Count > 24)
                    {
                        for (int i = alHostx.Count - 1; i > 0; i--)
                        {
                            if (alHostx[i]._Key.Trim() != "--Select Item ---")
                            {
                                alHostx.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    foreach (ComboBoxPair item in alHostx)
                    {
                        if (strNewHostName != item._Key && item._Key != "--Select Item ---")
                        {
                            boolNewItem = true;
                            alHostsNew.Add(item);
                        }
                    }

                    using (StreamWriter objSWFile = File.CreateText(settingsPath)) {
                        foreach (ComboBoxPair item in alHostsNew)
                        {
                            if (item._Key != "")
                            {
                                objSWFile.WriteLine(item._Key + '^' + item._Value);
                            }
                        }
                        objSWFile.Close();
                    }
                    goto DisplaySelectFolderWindowAgain;
                }
            }

            if (strButtonPressed == "btnOkay")
            {
                //if ((strFindWhat == "--Select Item ---" || strFindWhat == "")) {
                //    myActions.MessageBoxShow("Please enter Find What or select Find What from ComboBox; else press Cancel to Exit");
                //    goto DisplaySelectFolderWindow;
                //}

                if ((strFolder == "--Select Item ---" || strFolder == ""))
                {
                    myActions.MessageBoxShow("Please enter Folder or select Folder from ComboBox; else press Cancel to Exit");
                    goto DisplaySelectFolderWindow;
                }



                strFindWhatToUse = strFindWhat;

                if (_boolUseRegularExpression)
                {
                    strFindWhatToUse = strFindWhatToUse.Replace(")", "\\)").Replace("(", "\\(");
                }



                strFolderToUse = strFolder;
            }


            strPathToSearch = strFolderToUse;

            strSearchPattern = strFileTypeToUse;

            strSearchExcludePattern = strExcludeToUse;

            strSearchText = strFindWhatToUse;

            strLowerCaseSearchText = strFindWhatToUse.ToLower();
            myActions.SetValueByKey("FindWhatToUse", strFindWhatToUse);
        }
Ejemplo n.º 10
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("DDLMaint"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            string strCountries  = "";
            string strScriptsKey = "";

DisplayMainMenu:
            ControlEntity myControlEntity = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lblDDLMainMainMenu";
            myControlEntity.Text         = "Drop Down Lists Maint Main Menu";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnDropDownLists";
            myControlEntity.Text         = "Drop Down Lists";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnDropDownItems";
            myControlEntity.Text         = "Drop Down Items";
            myControlEntity.Width        = 150;
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType   = ControlType.ComboBox;
            myControlEntity.ID            = "Scripts";
            myControlEntity.Text          = "Drop Down Items";
            myControlEntity.Width         = 150;
            myControlEntity.RowNumber     = 3;
            myControlEntity.ColumnNumber  = 0;
            myControlEntity.SelectedValue = myActions.GetValueByKey("ScriptsDefaultValue");
            myControlEntity.SelectedKey   = myActions.GetValueByKey("ScriptsDefaultKey");
            strCountries  = myControlEntity.SelectedValue;
            strScriptsKey = myControlEntity.SelectedKey;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            if (strCountries != "--Select Item ---")
            {
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.ComboBox;
                myControlEntity.ID           = "Variables";
                myControlEntity.Text         = "Drop Down Items";
                myControlEntity.Width        = 150;
                myControlEntity.RowNumber    = 4;
                myControlEntity.ColumnNumber = 0;
                int intCountries = 0;
                Int32.TryParse(strCountries, out intCountries);
                myControlEntity.ParentLkDDLNamesItemsInc = intCountries;
                myControlEntity.SelectedValue            = "--Select Item ---";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
            }

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            strCountries  = myListControlEntity.Find(x => x.ID == "Scripts").SelectedValue;
            strScriptsKey = myListControlEntity.Find(x => x.ID == "Scripts").SelectedKey;
            myActions.SetValueByKey("ScriptsDefaultValue", strCountries);
            myActions.SetValueByKey("ScriptsDefaultKey", strScriptsKey);
            if (strCountries != "--Select Item ---" && strButtonPressed == "btnOkay")
            {
                goto DisplayMainMenu;
            }

            if (strButtonPressed == "btnDropDownLists")
            {
                myControlEntity     = new ControlEntity();
                myListControlEntity = new List <ControlEntity>();
                cbp = new List <ComboBoxPair>();
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Heading;
                myControlEntity.ID           = "lblMaintainDDL";
                myControlEntity.Text         = "Maintain DropDownLists";
                myControlEntity.RowNumber    = 0;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblID";
                myControlEntity.Text         = "ID";
                myControlEntity.RowNumber    = 1;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.TextBox;
                myControlEntity.ID           = "txtID";
                myControlEntity.Text         = "";
                myControlEntity.RowNumber    = 1;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblWidth";
                myControlEntity.Text         = "Width";
                myControlEntity.RowNumber    = 2;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.TextBox;
                myControlEntity.ID           = "txtWidth";
                myControlEntity.Text         = "";
                myControlEntity.RowNumber    = 2;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblDefaultSelectedValue";
                myControlEntity.Text         = "Default Selected Value";
                myControlEntity.RowNumber    = 3;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.TextBox;
                myControlEntity.ID           = "txtDefaultSelectedValue";
                myControlEntity.Text         = "";
                myControlEntity.RowNumber    = 3;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnAddDDL";
                myControlEntity.Text         = "Add DDL";
                myControlEntity.RowNumber    = 4;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblBlankLine";
                myControlEntity.Text         = " ";
                myControlEntity.RowNumber    = 5;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());


                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblddlIds";
                myControlEntity.Text         = "DDL IDs";
                myControlEntity.RowNumber    = 6;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.ComboBox;
                cbp.Clear();
                cbp.Add(new ComboBoxPair("--Select DDL to Delete ---", "--Select DDL to Delete ---"));
                SqlConnection con = new SqlConnection("Server=(local)\\SQLEXPRESS;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI");

                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = "SELECT * FROM DDLNames order by ID";
                cmd.Connection  = con;
                int intRow = 0;

                try {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    //(CommandBehavior.SingleRow)
                    while (reader.Read())
                    {
                        intRow++;
                        int    intInc = reader.GetInt32(0);
                        string strIDx = reader.GetString(1);
                        cbp.Add(new ComboBoxPair(strIDx, intInc.ToString()));
                    }
                    reader.Close();
                } finally {
                    con.Close();
                }
                myControlEntity.ListOfKeyValuePairs = cbp;
                myControlEntity.SelectedValue       = "";
                myControlEntity.ID            = "cbxddlIds";
                myControlEntity.RowNumber     = 6;
                myControlEntity.ColumnNumber  = 1;
                myControlEntity.SelectedValue = "--Select DDL to Delete ---";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnDeleteDDL";
                myControlEntity.Text         = "Delete DDL";
                myControlEntity.RowNumber    = 7;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);
                string strID    = myListControlEntity.Find(x => x.ID == "txtID").Text;
                string strWidth = myListControlEntity.Find(x => x.ID == "txtWidth").Text;
                string strDefaultSelectedValue = myListControlEntity.Find(x => x.ID == "txtDefaultSelectedValue").Text;
                string strddlIds = myListControlEntity.Find(x => x.ID == "cbxddlIds").SelectedValue;
                if (strButtonPressed == "btnAddDDL")
                {
                    SqlConnection thisConnection = new SqlConnection("server=.\\SQLEXPRESS;" + "integrated security=sspi;database=IdealAutomateDB");
                    //Create Command object
                    SqlCommand nonqueryCommand                  = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_delete           = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_insert_page_name = thisConnection.CreateCommand();
                    try {
                        // Open Connection
                        thisConnection.Open();
                        // Console.WriteLine("Connection Opened");


                        // Create INSERT statement with named parameters
                        nonqueryCommand.CommandText = "IF NOT EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM DDLNames " +
                                                      " WHERE ID = @ID " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " INSERT  INTO DDLNames (ID, Width, DefaultValue) VALUES (@ID, @Width, @DefaultValue)" +
                                                      " END ";

                        // Add Parameters to Command Parameters collection
                        nonqueryCommand.Parameters.Add("@ID", SqlDbType.VarChar, 500);
                        nonqueryCommand.Parameters["@ID"].Value = strID;
                        nonqueryCommand.Parameters.Add("@Width", SqlDbType.Int);
                        if (strWidth.Trim() == "")
                        {
                            strWidth = "0";
                        }
                        nonqueryCommand.Parameters["@Width"].Value = strWidth;
                        nonqueryCommand.Parameters.Add("@DefaultValue", SqlDbType.VarChar, -1);
                        nonqueryCommand.Parameters["@DefaultValue"].Value = strDefaultSelectedValue;

                        // Prepare command for repeated execution
                        nonqueryCommand.Prepare();
                        int intRowsModified = nonqueryCommand.ExecuteNonQuery();
                        if (intRowsModified < 1)
                        {
                            myActions.MessageBoxShow("Record not added - ID probably already exists; delete before adding to modify");
                        }
                    } catch (SqlException ex) {
                        // Display error
                        //Console.WriteLine("Error: " + ex.ToString());
                        myActions.MessageBoxShow("Error: " + ex.ToString());
                    }
                    goto DisplayMainMenu;
                }
                if (strButtonPressed == "btnDeleteDDL")
                {
                    SqlConnection thisConnection = new SqlConnection("server=.\\SQLEXPRESS;" + "integrated security=sspi;database=IdealAutomateDB");
                    //Create Command object
                    SqlCommand nonqueryCommand                  = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_delete           = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_insert_page_name = thisConnection.CreateCommand();
                    try {
                        // Open Connection
                        thisConnection.Open();
                        // Console.WriteLine("Connection Opened");


                        // Create INSERT statement with named parameters
                        nonqueryCommand.CommandText = "IF EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM DDLNames " +
                                                      " WHERE INC = @INC " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " DELETE FROM DDLNames WHERE INC = @INC" +
                                                      " END ";

                        // Add Parameters to Command Parameters collection

                        nonqueryCommand.Parameters.Add("@INC", SqlDbType.Int);
                        if (strWidth.Trim() == "")
                        {
                            strWidth = "0";
                        }
                        int intDeleteInc = 0;
                        Int32.TryParse(strddlIds, out intDeleteInc);
                        nonqueryCommand.Parameters["@INC"].Value = intDeleteInc;


                        // Prepare command for repeated execution
                        nonqueryCommand.Prepare();
                        int intRowsModified = nonqueryCommand.ExecuteNonQuery();
                        if (intRowsModified < 1)
                        {
                            myActions.MessageBoxShow("Record not deleted");
                        }
                    } catch (SqlException ex) {
                        // Display error
                        //Console.WriteLine("Error: " + ex.ToString());
                        myActions.MessageBoxShow("Error: " + ex.ToString());
                    }
                    goto DisplayMainMenu;
                }
            }

            if (strButtonPressed == "btnDropDownItems")
            {
                myControlEntity     = new ControlEntity();
                myListControlEntity = new List <ControlEntity>();
                cbp = new List <ComboBoxPair>();
                List <ComboBoxPair> cbp1 = new List <ComboBoxPair>();
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Heading;
                myControlEntity.ID           = "lblMaintainDDLItems";
                myControlEntity.Text         = "Maintain DropDownList Items";
                myControlEntity.RowNumber    = 0;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());



                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblParentddlIds";
                myControlEntity.Text         = "Optional Parent DDL IDs";
                myControlEntity.RowNumber    = 1;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.ComboBox;
                cbp.Clear();
                cbp.Add(new ComboBoxPair("--Select Parent DDL to Maintain ---", "-1"));
                SqlConnection con = new SqlConnection("Server=(local)\\SQLEXPRESS;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI");

                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = "SELECT * FROM DDLNames order by ID";
                cmd.Connection  = con;
                int intRow = 0;

                try {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    //(CommandBehavior.SingleRow)
                    while (reader.Read())
                    {
                        intRow++;
                        int    intInc = reader.GetInt32(0);
                        string strIDx = reader.GetString(1);
                        cbp.Add(new ComboBoxPair(strIDx, intInc.ToString()));
                    }
                    reader.Close();
                } finally {
                    con.Close();
                }
                myControlEntity.ListOfKeyValuePairs = cbp;
                myControlEntity.SelectedValue       = "";
                myControlEntity.ID            = "cbxParentddlIds";
                myControlEntity.RowNumber     = 1;
                myControlEntity.ColumnNumber  = 1;
                myControlEntity.SelectedValue = "-1";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblddlIds";
                myControlEntity.Text         = "DDL IDs";
                myControlEntity.RowNumber    = 2;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.ComboBox;
                cbp1.Clear();
                cbp1.Add(new ComboBoxPair("--Select DDL to Maintain ---", "--Select DDL to Maintain ---"));
                con = new SqlConnection("Server=(local)\\SQLEXPRESS;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI");

                cmd = new SqlCommand();

                cmd.CommandText = "SELECT * FROM DDLNames order by ID";
                cmd.Connection  = con;
                intRow          = 0;

                try {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    //(CommandBehavior.SingleRow)
                    while (reader.Read())
                    {
                        intRow++;
                        int    intInc = reader.GetInt32(0);
                        string strIDx = reader.GetString(1);
                        cbp1.Add(new ComboBoxPair(strIDx, intInc.ToString()));
                    }
                    reader.Close();
                } finally {
                    con.Close();
                }
                myControlEntity.ListOfKeyValuePairs = cbp1;
                myControlEntity.SelectedValue       = "";
                myControlEntity.ID            = "cbxddlIds";
                myControlEntity.RowNumber     = 2;
                myControlEntity.ColumnNumber  = 1;
                myControlEntity.SelectedValue = "--Select DDL to Maintain ---";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnAddItem";
                myControlEntity.Text         = "Add Item";
                myControlEntity.RowNumber    = 3;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnDeleteItem";
                myControlEntity.Text         = "Delete Item";
                myControlEntity.RowNumber    = 4;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
DisplayMenu:
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);
                string strddlIds       = myListControlEntity.Find(x => x.ID == "cbxddlIds").SelectedValue;
                string strParentddlIds = myListControlEntity.Find(x => x.ID == "cbxParentddlIds").SelectedValue;
                if (strddlIds == "--Select DDL to Maintain ---" && (strButtonPressed == "btnAddItem" || strButtonPressed == "btnDeleteItem"))
                {
                    myActions.MessageBoxShow("Please select DDL to maintain");
                    goto DisplayMenu;
                }
                if (strButtonPressed == "btnAddItem")
                {
                    myControlEntity     = new ControlEntity();
                    myListControlEntity = new List <ControlEntity>();
                    cbp = new List <ComboBoxPair>();

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Label;
                    myControlEntity.ID           = "lblddlItems";
                    myControlEntity.Text         = "Optional Parent DDL Items";
                    myControlEntity.RowNumber    = 1;
                    myControlEntity.ColumnNumber = 0;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    if (strParentddlIds != "-1")
                    {
                        myControlEntity.ControlEntitySetDefaults();
                        myControlEntity.ControlType = ControlType.ComboBox;
                        cbp.Clear();
                        cbp.Add(new ComboBoxPair("--Select Optional Parent Item ---", "-1"));
                        con = new SqlConnection("Server=(local)\\SQLEXPRESS;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI");

                        cmd = new SqlCommand();

                        cmd.CommandText = "SELECT lk.inc, i.listItemKey, i.ListItemValue FROM LkDDLNamesItems lk " +
                                          "join DDLNames n on n.inc = lk.DDLNamesInc " +
                                          "join DDLItems i on i.inc = lk.ddlItemsInc " +
                                          "where DDLNamesInc = @DDLNamesInc ";
                        cmd.Parameters.Add("@DDLNamesInc", SqlDbType.Int);
                        int intDeleteInc = 0;
                        Int32.TryParse(strParentddlIds, out intDeleteInc);
                        cmd.Parameters["@DDLNamesInc"].Value = intDeleteInc;
                        cmd.Connection = con;

                        intRow = 0;

                        try {
                            con.Open();
                            SqlDataReader reader = cmd.ExecuteReader();
                            //(CommandBehavior.SingleRow)
                            while (reader.Read())
                            {
                                intRow++;
                                int    intInc = reader.GetInt32(0);
                                string strIDx = reader.GetString(1);
                                cbp.Add(new ComboBoxPair(strIDx, intInc.ToString()));
                            }
                            reader.Close();
                        } finally {
                            con.Close();
                        }
                        myControlEntity.ListOfKeyValuePairs = cbp;
                        myControlEntity.SelectedValue       = "";
                        myControlEntity.ID            = "cbxParentddlItems";
                        myControlEntity.RowNumber     = 1;
                        myControlEntity.ColumnNumber  = 1;
                        myControlEntity.SelectedValue = "-1";
                        myListControlEntity.Add(myControlEntity.CreateControlEntity());
                    }

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Label;
                    myControlEntity.ID           = "lblKey";
                    myControlEntity.Text         = "Key";
                    myControlEntity.RowNumber    = 2;
                    myControlEntity.ColumnNumber = 0;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.TextBox;
                    myControlEntity.ID           = "txtKey";
                    myControlEntity.Text         = "";
                    myControlEntity.RowNumber    = 2;
                    myControlEntity.ColumnNumber = 1;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());


                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Label;
                    myControlEntity.ID           = "lblValue";
                    myControlEntity.Text         = "Value";
                    myControlEntity.RowNumber    = 3;
                    myControlEntity.ColumnNumber = 0;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.TextBox;
                    myControlEntity.ID           = "txtValue";
                    myControlEntity.Text         = "";
                    myControlEntity.RowNumber    = 3;
                    myControlEntity.ColumnNumber = 1;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Button;
                    myControlEntity.ID           = "btnAddItem";
                    myControlEntity.Text         = "Add Item";
                    myControlEntity.RowNumber    = 4;
                    myControlEntity.ColumnNumber = 1;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());
                    strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);
                    string strKey            = myListControlEntity.Find(x => x.ID == "txtKey").Text;
                    string strValue          = myListControlEntity.Find(x => x.ID == "txtValue").Text;
                    string strParentddlItems = "-1";
                    if (strParentddlIds != "-1")
                    {
                        strParentddlItems = myListControlEntity.Find(x => x.ID == "cbxParentddlItems").SelectedValue;
                    }
                    // TODO: 1. See if key value pair exists in DDLItems
                    // if it exists, save the inc
                    // if it does not exist, add it to DDLItems and get the inc
                    // add record to LK table with DDLNameInc and DDLItemInc if it does
                    // not already exist
                    SqlConnection thisConnection = new SqlConnection("server=.\\SQLEXPRESS;" + "integrated security=sspi;database=IdealAutomateDB");
                    //Create Command object
                    SqlCommand nonqueryCommand                  = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_delete           = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_insert_page_name = thisConnection.CreateCommand();
                    try {
                        // Open Connection
                        thisConnection.Open();
                        // Console.WriteLine("Connection Opened");


                        // Create INSERT statement with named parameters
                        nonqueryCommand.CommandText = "IF NOT EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM DDLItems " +
                                                      " WHERE ListItemKey = @ListItemKey " +
                                                      " AND ListItemValue = @ListItemValue " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " INSERT  INTO DDLItems (ListItemKey, ListItemValue) VALUES (@ListItemKey, @ListItemValue)" +
                                                      " END " +
                                                      " DECLARE @DDLItemsInc int;" +
                                                      " set @DDLItemsInc =   (SELECT Top 1 Inc " +
                                                      " FROM DDLItems " +
                                                      " WHERE ListItemKey = @ListItemKey " +
                                                      " AND ListItemValue = @ListItemValue); " +
                                                      "IF NOT EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM LKDdlNamesItems " +
                                                      " WHERE DDLNamesInc = @DDLNamesInc " +
                                                      " AND DDLItemsInc = @DDLItemsInc " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " INSERT  INTO LKDdlNamesItems (ParentLkDDLNamesItemsInc,DDLNamesInc, DDLItemsInc) VALUES (@ParentLkDDLNamesItemsInc, @DDLNamesInc, @DDLItemsInc)" +

                                                      " END ";

                        // Add Parameters to Command Parameters collection

                        nonqueryCommand.Parameters.Add("@ListItemKey", SqlDbType.VarChar, -1);
                        nonqueryCommand.Parameters["@ListItemKey"].Value = strKey;
                        nonqueryCommand.Parameters.Add("@ListItemValue", SqlDbType.VarChar, -1);
                        nonqueryCommand.Parameters["@ListItemValue"].Value = strValue;
                        nonqueryCommand.Parameters.Add("@DDLNamesInc", SqlDbType.Int);
                        int intDDLNamesInc = 0;
                        Int32.TryParse(strddlIds, out intDDLNamesInc);
                        nonqueryCommand.Parameters["@DDLNamesInc"].Value = intDDLNamesInc;
                        nonqueryCommand.Parameters.Add("@ParentLkDDLNamesItemsInc", SqlDbType.Int);
                        int intParentLkDDLNamesItemsInc = 0;
                        Int32.TryParse(strParentddlItems, out intParentLkDDLNamesItemsInc);
                        nonqueryCommand.Parameters["@ParentLkDDLNamesItemsInc"].Value = intParentLkDDLNamesItemsInc;


                        // Prepare command for repeated execution
                        nonqueryCommand.Prepare();
                        int intRowsModified = nonqueryCommand.ExecuteNonQuery();
                        if (intRowsModified < 1)
                        {
                            myActions.MessageBoxShow("Record not added");
                        }
                    } catch (SqlException ex) {
                        // Display error
                        //Console.WriteLine("Error: " + ex.ToString());
                        myActions.MessageBoxShow("Error: " + ex.ToString());
                    }
                    goto DisplayMainMenu;
                }

                if (strButtonPressed == "btnDeleteItem")
                {
                    myControlEntity     = new ControlEntity();
                    myListControlEntity = new List <ControlEntity>();
                    cbp = new List <ComboBoxPair>();

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Label;
                    myControlEntity.ID           = "lblddlItems";
                    myControlEntity.Text         = "DDL Items";
                    myControlEntity.RowNumber    = 6;
                    myControlEntity.ColumnNumber = 0;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType = ControlType.ComboBox;
                    cbp1.Clear();
                    cbp1.Add(new ComboBoxPair("--Select Item to Delete ---", "--Select Item to Delete ---"));
                    con = new SqlConnection("Server=(local)\\SQLEXPRESS;Initial Catalog=IdealAutomateDB;Integrated Security=SSPI");

                    cmd = new SqlCommand();

                    cmd.CommandText = "SELECT lk.inc, i.listItemKey, i.ListItemValue FROM LkDDLNamesItems lk " +
                                      "join DDLNames n on n.inc = lk.DDLNamesInc " +
                                      "join DDLItems i on i.inc = lk.ddlItemsInc " +
                                      "where DDLNamesInc = @DDLNamesInc ";
                    cmd.Parameters.Add("@DDLNamesInc", SqlDbType.Int);
                    int intDeleteInc = 0;
                    Int32.TryParse(strddlIds, out intDeleteInc);
                    cmd.Parameters["@DDLNamesInc"].Value = intDeleteInc;
                    cmd.Connection = con;

                    intRow = 0;

                    try {
                        con.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        //(CommandBehavior.SingleRow)
                        while (reader.Read())
                        {
                            intRow++;
                            int    intInc = reader.GetInt32(0);
                            string strIDx = reader.GetString(1);
                            cbp1.Add(new ComboBoxPair(strIDx, intInc.ToString()));
                        }
                        reader.Close();
                    } finally {
                        con.Close();
                    }
                    myControlEntity.ListOfKeyValuePairs = cbp1;
                    myControlEntity.SelectedValue       = "";
                    myControlEntity.ID            = "cbxddlItems";
                    myControlEntity.RowNumber     = 6;
                    myControlEntity.ColumnNumber  = 1;
                    myControlEntity.SelectedValue = "--Select Item to Delete ---";
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType  = ControlType.Button;
                    myControlEntity.ID           = "btnDeleteItem";
                    myControlEntity.Text         = "Delete Item";
                    myControlEntity.RowNumber    = 7;
                    myControlEntity.ColumnNumber = 1;
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                    strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);
                    string strddlItems = myListControlEntity.Find(x => x.ID == "cbxddlItems").SelectedValue;


                    SqlConnection thisConnection = new SqlConnection("server=.\\SQLEXPRESS;" + "integrated security=sspi;database=IdealAutomateDB");
                    //Create Command object
                    SqlCommand nonqueryCommand                  = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_delete           = thisConnection.CreateCommand();
                    SqlCommand nonqueryCommand_insert_page_name = thisConnection.CreateCommand();
                    try {
                        // Open Connection
                        thisConnection.Open();
                        // Console.WriteLine("Connection Opened");


                        // Create INSERT statement with named parameters
                        nonqueryCommand.CommandText = "IF EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM LkDDLNamesItems " +
                                                      " WHERE INC = @INC " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " DECLARE @DDLItemsInc int;" +
                                                      " SET @DDLItemsInc = (  SELECT DDLItemsInc " +
                                                      " FROM LkDDLNamesItems " +
                                                      " WHERE INC = @INC); " +
                                                      " DELETE FROM LKDDLNamesItems WHERE INC = @INC;" +
                                                      "IF NOT EXISTS (" +
                                                      " SELECT * " +
                                                      " FROM LkDDLNamesItems " +
                                                      " WHERE DDLItemsInc = @DDLItemsInc " +
                                                      " ) " +
                                                      " BEGIN " +
                                                      " DELETE FROM DDLItems WHERE INC = @DDLItemsInc;" +
                                                      " END " +
                                                      " END ";

                        // Add Parameters to Command Parameters collection

                        nonqueryCommand.Parameters.Add("@INC", SqlDbType.Int);
                        intDeleteInc = 0;
                        Int32.TryParse(strddlItems, out intDeleteInc);
                        nonqueryCommand.Parameters["@INC"].Value = intDeleteInc;


                        // Prepare command for repeated execution
                        nonqueryCommand.Prepare();
                        int intRowsModified = nonqueryCommand.ExecuteNonQuery();
                        if (intRowsModified < 1)
                        {
                            myActions.MessageBoxShow("Record not deleted");
                        }
                    } catch (SqlException ex) {
                        // Display error
                        //Console.WriteLine("Error: " + ex.ToString());
                        myActions.MessageBoxShow("Error: " + ex.ToString());
                    }
                    goto DisplayMainMenu;
                }
            }



            goto myExit;

myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 11
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            //myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("HotKeysMenu"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);

SearchDialog:
            searchDialogRtn();
            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                return;
            }

            string[] files = null;
            if (strHotkeysOnly == "All Executables")
            {
                try {
                    //List<FileInfo> myFileList = TraverseTree("*.exe", strFolder);
                    //Array.Resize(ref files, myFileList.Count);
                    //for (int i = 0; i < myFileList.Count; i++) {
                    //    var item = myFileList[i];

                    //    files[i] = item.FullName;
                    //}
                    files = GetFiles(strFolder, "*.exe|*.lnk", SearchOption.AllDirectories);
                } catch (UnauthorizedAccessException e) {
                    myActions.MessageBoxShow(e.Message + " - line 162 in HotKeysMenu");
                    Console.WriteLine(e.Message);
                } catch (System.IO.DirectoryNotFoundException e) {
                    Console.WriteLine(e.Message);
                } catch (System.IO.PathTooLongException e) {
                    Console.WriteLine(e.Message);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }

                // Perform the required action on each file here.
                // Modify this block to perform your required task.
                if (files == null)
                {
                    myActions.MessageBoxShow("No executable files found");
                    goto SearchDialog;
                }
            }
            else
            {
                ArrayList arrayListScriptInfo = myActions.ReadAppDirectoryKeyToArrayListGlobal("ScriptInfo");
                Array.Resize(ref files, arrayListScriptInfo.Count);
                for (int i = 0; i < arrayListScriptInfo.Count; i++)
                {
                    var      item   = arrayListScriptInfo[i];
                    string[] myCols = item.ToString().Split('^');
                    // myCols[0] has scriptname after last hyphen
                    // myCols[1] has shortcut key
                    // myCols[5] has executable
                    files[i] = myCols[5];
                }
            }
            foreach (string myFile in files)
            {
                if (!myFile.ToUpper().Contains("VSHOST") && !myFile.ToUpper().Contains(@"\OBJ\"))
                {
                    AddToListCategoryMethods(myFile);
                }
            }

            // Loop thru array of categories and methods
            // When you encounter new category, write red label; else write grey button
            // The name for each button is myButton followed by method name
            // If there are more than 20 rows, start a new column
            // If there are more than 18 rows, and you encounter a new category, start
            // new column so you do not have category at the bottom without any methods
            // below it
            int    intWindowTop  = 0;
            int    intWindowLeft = 0;
            string strWindowTop  = "";
            string strWindowLeft = "";

            intRowCtr = 0;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            intEndPageMethod = listCategoryMethod.Count();
            intTotalMethods  = listCategoryMethod.Count();
BuildMenuDialogPage:
            myListControlEntity = new List <ControlEntity>();

            myControlEntity = new ControlEntity();
            intCol          = 0;
            intRow          = 0;
            intRowCtr       = 0;
            if (intStartPageMethod < 0)
            {
                intStartPageMethod = 0;
            }
            intEndPageMethod = intStartPageMethod + intPageSize;
            if (intEndPageMethod > intTotalMethods)
            {
                intEndPageMethod = intTotalMethods;
            }
            for (int i = intStartPageMethod; i < intEndPageMethod; i++)
            {
                var      item          = listCategoryMethod.ToList()[i];
                string[] myArrayFields = item.Key.Replace("Category::", "").ToString().Split('^');
                {
                    intRow++;
                    if (intRow > 20)
                    {
                        intRow = 1;
                        intCol++;
                    }
                    string strMethodName = myArrayFields[1];
                    string strCategory   = myArrayFields[0];
                    string strExecutable = myArrayFields[2];

                    if (strCategory != strPreviousCategory)
                    {
                        if (intRow > 18)
                        {
                            intRow = 1;
                            intCol++;
                        }
                        myControlEntity.ControlEntitySetDefaults();
                        myControlEntity.ControlType     = ControlType.Label;
                        myControlEntity.ID              = "lbl" + strCategory.Replace(" ", "").Replace("<", "").Replace(">", "").Replace("#", "").Replace("+", "");
                        myControlEntity.Text            = strCategory;
                        myControlEntity.RowNumber       = intRow;
                        myControlEntity.ColumnNumber    = intCol;
                        myControlEntity.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
                        myControlEntity.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
                        myListControlEntity.Add(myControlEntity.CreateControlEntity());
                        strPreviousCategory = strCategory;
                        intRow++;
                    }
                    myControlEntity.ControlEntitySetDefaults();
                    myControlEntity.ControlType = ControlType.Button;
                    myControlEntity.ID          = "myButton" + strMethodName.Replace(" ", "").Replace("<", "").Replace(">", "").Replace("=", "").Replace("!", "").Replace("#", "").Replace("+", "");
                    myControlEntity.Text        = strMethodName;
                    myControlEntity.ToolTipx    = strExecutable;

                    myControlEntity.RowNumber    = intRow;
                    myControlEntity.ColumnNumber = intCol;
                    //    myControlEntity.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
                    //   myControlEntity.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
                    myListControlEntity.Add(myControlEntity.CreateControlEntity());
                }
            }



            intRow++;
            if (intRow > 15)
            {
                intRow = 1;
                intCol++;
            }
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "(" + intStartPageMethod.ToString() + " to " + intEndPageMethod.ToString() + ") of Total Executables: " + intTotalMethods.ToString();
            myControlEntity.RowNumber    = intRow;
            myControlEntity.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity.ColumnNumber = intCol;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            if (intStartPageMethod > 0)
            {
                intRow++;
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnPrev";
                myControlEntity.Text         = "Prev";
                myControlEntity.RowNumber    = intRow;
                myControlEntity.ColumnNumber = intCol;
                //    myControlEntity.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
                //   myControlEntity.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
            }

            if (intEndPageMethod < intTotalMethods)
            {
                intRow++;
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Button;
                myControlEntity.ID           = "btnNext";
                myControlEntity.Text         = "Next";
                myControlEntity.RowNumber    = intRow;
                myControlEntity.ColumnNumber = intCol;
                //    myControlEntity.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
                //   myControlEntity.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
            }


            intRow++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Button;
            myControlEntity.ID           = "btnSearch";
            myControlEntity.Text         = "Search";
            myControlEntity.RowNumber    = intRow;
            myControlEntity.ColumnNumber = intCol;
            //    myControlEntity.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
            //   myControlEntity.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            string strScripts         = "";
            string strVariables       = "";
            string strVariablesValue  = "";
            string strScripts1        = "";
            string strVariables1      = "";
            string strScripts2        = "";
            string strVariables2      = "";
            string strVariables1Value = "";
            string strVariables2Value = "";
            int    intWidth           = (intCol + 1) * intColumnWidth;

            GetSavedWindowPosition(myActions, out intWindowTop, out intWindowLeft, out strWindowTop, out strWindowLeft);
            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 650, intWidth, intWindowTop, intWindowLeft);
DisplayWindowAgain:

            if (strButtonPressed == "btnCancel")
            {
                // myActions.MessageBoxShow(strButtonPressed);
                goto myExit;
            }
            if (strButtonPressed == "btnOkay")
            {
                //  myActions.MessageBoxShow(strButtonPressed);
                goto myExit;
            }
            if (strButtonPressed == "btnPrev")
            {
                //  myActions.MessageBoxShow(strButtonPressed);
                intStartPageMethod = intStartPageMethod - intPageSize;
                goto BuildMenuDialogPage;
            }
            if (strButtonPressed == "btnNext")
            {
                //  myActions.MessageBoxShow(strButtonPressed);
                if (intStartPageMethod + intPageSize < intTotalMethods)
                {
                    intStartPageMethod = intStartPageMethod + intPageSize;
                }
                goto BuildMenuDialogPage;
            }
            if (strButtonPressed == "btnSearch")
            {
                //  myActions.MessageBoxShow(strButtonPressed);
                goto SearchDialog;
            }
            strMethod = strButtonPressed.Replace("myButton", "");
            string strExecutablex = "";

            if (strExecuteCategorize == "Execute")
            {
                foreach (var item in listCategoryMethod)
                {
                    string[] myArrayFields = item.Key.Replace("Category::", "").ToString().Split('^');

                    string strMethodName = myArrayFields[1].Replace(" ", "");
                    string strCategory   = myArrayFields[0];
                    if (strMethod == strMethodName)
                    {
                        strExecutablex = myArrayFields[2];
                    }
                }
                if (strExecutablex != "")
                {
                    if (strExecutablex.EndsWith(".lnk"))
                    {
                        myActions.Run(GetShortcutTargetFile(strExecutablex), "");
                    }
                    else
                    {
                        myActions.Run(strExecutablex, "");
                    }
                    myActions.Sleep(1000);
                    GetSavedWindowPosition(myActions, out intWindowTop, out intWindowLeft, out strWindowTop, out strWindowLeft);
                    // Display main menu and go back to where you
                    // process input from main menu
                    intWidth         = (intCol + 1) * intColumnWidth;
                    strButtonPressed = myActions.WindowMultipleControlsMinimized(ref myListControlEntity, 650, intWidth, intWindowTop, intWindowLeft);
                    goto DisplayWindowAgain;
                }
            }
            else
            {
                ControlEntity        myControlEntity1     = new ControlEntity();
                List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
                cbp  = new List <ComboBoxPair>();
                cbp1 = new List <ComboBoxPair>();
DisplayIEGoToURLWindow:
                myControlEntity1     = new ControlEntity();
                myListControlEntity1 = new List <ControlEntity>();
                cbp = new List <ComboBoxPair>();

                // Row 0 is heading that says:
                // IE Go To URL
                intRowCtr = 0;
                myControlEntity1.ControlEntitySetDefaults();
                myControlEntity1.ControlType  = ControlType.Heading;
                myControlEntity1.ID           = "lbl" + strMethod.Replace("<", "").Replace(">", "").Replace("+", "");
                myControlEntity1.Text         = strMethod;
                myControlEntity1.Width        = 300;
                myControlEntity1.RowNumber    = 0;
                myControlEntity1.ColumnNumber = 0;
                myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

                intRowCtr++;
                myControlEntity1.ControlEntitySetDefaults();
                myControlEntity1.ControlType  = ControlType.Label;
                myControlEntity1.ID           = "lblCategory";
                myControlEntity1.Text         = "Category (optional):";
                myControlEntity1.RowNumber    = intRowCtr;
                myControlEntity1.ColumnNumber = 0;
                myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



                myControlEntity1.ControlEntitySetDefaults();
                myControlEntity1.ControlType = ControlType.ComboBox;
                if (strMethod.StartsWith("Window"))
                {
                    var debug = true;
                }
                myControlEntity1.SelectedValue = myActions.GetValueByKey("cbxCategory" + strMethod + "SelectedValue");
                string myFolder = myActions.GetValueByKey("cbxFolderSelectedValue");

                myControlEntity1.ID        = "cbxCategory_" + GetSafeFilename(myFolder);
                myControlEntity1.RowNumber = intRowCtr;
                myControlEntity1.ToolTipx  = "";
                //foreach (var item in alcbxFindWhat) {
                //    cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
                //}
                //myControlEntity1.ListOfKeyValuePairs = cbp;
                myControlEntity1.ComboBoxIsEditable = true;
                myControlEntity1.ColumnNumber       = 1;

                myControlEntity1.ColumnSpan = 2;
                myListControlEntity1.Add(myControlEntity1.CreateControlEntity());


                // Get saved position of window from roaming..
                GetSavedWindowPosition(myActions, out intWindowTop, out intWindowLeft, out strWindowTop, out strWindowLeft);
                // Display input dialog
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 700, 1200, intWindowTop, intWindowLeft);
                // Get Values from input dialog and save to roaming



                // if okay button pressed, validate inputs; place inputs into syntax; put generated
                // code into clipboard and display generated code
                if (strButtonPressed == "btnOkay")
                {
                    //if (strWebsiteURLx == "" && strVariables == "--Select Item ---") {
                    //    myActions.MessageBoxShow("Please enter Website URL or select script variable; else press Cancel to Exit");
                    //    goto DisplayIEGoToURLWindow;
                    //}
                    //string strWebsiteURLToUse = "";
                    //if (strWebsiteURLx.Trim() == "") {
                    //    strWebsiteURLToUse = strVariables;
                    //} else {
                    //    strWebsiteURLToUse = "\"" + strWebsiteURLx.Trim() + "\"";
                    //}
                    myFolder = myActions.GetValueByKey("cbxFolderSelectedValue");


                    string strCategory = myListControlEntity1.Find(x => x.ID == "cbxCategory_" + GetSafeFilename(myFolder)).SelectedValue;

                    myActions.SetValueByKey("cbxCategory" + strMethod.Replace("<", "").Replace(">", "").Replace("+", "") + "SelectedValue", strCategory);
                }
                GetSavedWindowPosition(myActions, out intWindowTop, out intWindowLeft, out strWindowTop, out strWindowLeft);
                // Display main menu and go back to where you
                // process input from main menu
                intWidth         = (intCol + 1) * intColumnWidth;
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 650, intWidth, intWindowTop, intWindowLeft);
                goto DisplayWindowAgain;
            }

myExit:
            //   myActions.ScriptStartedUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 12
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("WrapHtmlInResponseWrite"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            string strExecutable = @"C:\Windows\system32\notepad.exe";
            string strContent    = @"C:\Data\HTML_In.txt";

            Process.Start(strExecutable, string.Concat("", strContent, ""));
            myActions.WindowShape("RedBox", "", "Step 1", " Put your html in the notepad file that just opened and save it. \nHit Okay button to continue to next step ", 0, 0);
            string strInFile = @"C:\Data\HTML_In.txt";
            // private string strInFile = @"C:\Data\LanguageXMLInput3.txt";
            string        strOutFile           = @"C:\Data\HTML_Out_Wrapped.txt";
            List <string> listOfSolvedProblems = new List <string>();
            List <string> listofRecs           = new List <string>();

            string[] lineszz = System.IO.File.ReadAllLines(strInFile);


            using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile)) {
                int intLineCount = lineszz.Count();
                int intCtr       = 0;
                foreach (string line in lineszz)
                {
                    intCtr++;
                    // if line contains response.write, do not modify and write as is
                    if (line.ToLower().Contains("response.write"))
                    {
                        file.WriteLine(line);
                        continue;
                    }
                    // replace double quotes with two double quotes because that is how classic escapes double quote
                    string linex = line.Replace("\"", "\"\"");
                    // wrap line with Response.Write opening double quote and closing double quote
                    file.WriteLine("Response.Write \"" + linex + " \"");
                }
            }
            strExecutable = @"C:\Windows\system32\notepad.exe";
            strContent    = strOutFile;
            Process.Start(strExecutable, string.Concat("", strContent, ""));

            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"");
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgPatch2015_08_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgPatch2015_08.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 30;
            myImage.RelativeY = 10;


            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of " + myImage.ImageFile);
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.RightClick(myArray);

            myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            myActions.Run(@"C:\Program Files\Microsoft Office\Office15\EXCEL.EXE", @"C:\SVNStats\SVNStats.xlsx");
myExit:
            Application.Current.Shutdown();
        }
Ejemplo n.º 13
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("PositionCursor"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayPositionCursor:
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp       = new List <ComboBoxPair>();
            intRowCtr = 0;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblPositionCursor";
            myControlEntity1.Text         = "PositionCursor";
            myControlEntity1.Width        = 300;
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSyntax2";
            myControlEntity1.Text         = "myActions.PositionCursor([[myArray]]);";
            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblInput";
            myControlEntity1.Text         = "Input:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblmyArray";
            myControlEntity1.Text         = "myArray:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtmyArray";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorPositionCursormyArray");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblExample";
            myControlEntity1.Text         = "Example:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.TextBox;
            myControlEntity1.ID          = "txtExample";
            myControlEntity1.Height      = 250;
            myControlEntity1.Text        = "      ImageEntity myImage = new ImageEntity(); \r\n" +
                                           " \r\n" +
                                           "      if (boolRunningFromHome) { \r\n" +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[homeimage]]\");  \r\n " +
                                           "      } else { \r\n " +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[workimage]]\"); \r\n " +
                                           "      } \r\n" +
                                           "      myImage.Sleep = 200; \r\n" +
                                           "      myImage.Attempts = 5; \r\n" +
                                           "      myImage.RelativeX = 10; \r\n" +
                                           "      myImage.RelativeY = 10; \r\n" +
                                           " \r\n" +
                                           "      int[,] myArray = myActions.PutAll(myImage); \r\n" +
                                           "      if (myArray.Length == 0) { \r\n" +
                                           "        myActions.MessageBoxShow(\"I could not find image of SVN Update\"); \r\n" +
                                           "      } \r\n" +
                                           "      // We found output completed and now want to copy the results \r\n" +
                                           "      // to notepad \r\n" +
                                           " \r\n" +
                                           "      // Highlight the output completed line \r\n" +
                                           "      myActions.Sleep(1000); \r\n" +
                                           "      myActions.PositionCursor(myArray); ";

            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 650, 700, intWindowTop, intWindowLeft);

            string strmyArray = myListControlEntity1.Find(x => x.ID == "txtmyArray").Text;

            myActions.SetValueByKey("ScriptGeneratorPositionCursormyArray", strmyArray);


            if (strButtonPressed == "btnOkay")
            {
                string strmyArrayToUse = "";

                strmyArrayToUse = strmyArray.Trim();

                string strGeneratedLinex = "";

                strGeneratedLinex = "myActions.PositionCursor(" + strmyArrayToUse + ");";

                myActions.PutEntityInClipboard(strGeneratedLinex);
                myActions.MessageBoxShow(strGeneratedLinex + Environment.NewLine + Environment.NewLine + "The generated text has been put into your clipboard");
            }

myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 14
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("SaveClipboardToFile"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intRowCtr           = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lbl";
            myControlEntity.Text         = "File Name for Saved Clip";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblFileName";
            myControlEntity.Text         = "FileName:";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtFileName";
            myControlEntity.Text         = myActions.GetValueByKey("FileName");;
            myControlEntity.ToolTipx     = "Enter filename for saved clip";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string strFileName = myListControlEntity.Find(x => x.ID == "txtFileName").Text;
            string fileName1   = @"C:\Data\Clips\" + strFileName;

            ReadOnlyCollection <DataClip> myClipData = ClipboardHelper.GetClipboard();

            ClipboardHelper.SaveToFile(myClipData, fileName1);

myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 15
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("TypeText"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayTypeText:
            myListControlEntity1 = new List <ControlEntity>();

            myControlEntity1 = new ControlEntity();
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.Heading;
            myControlEntity1.Text        = "Script Generator";
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblTextToType";
            myControlEntity1.Text         = "Text to Type:";
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtTextToType";
            myControlEntity1.Text         = "";
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 1;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());


            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblMilliSecondsToWait";
            myControlEntity1.Text         = "Milliseconds to Wait:";
            myControlEntity1.RowNumber    = 1;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strDefaultMilliseconds = myActions.GetValueByKey("ScriptGeneratorDefaultMilliseconds");

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtMillisecondsToWait";
            myControlEntity1.Text         = strDefaultMilliseconds;
            myControlEntity1.RowNumber    = 1;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblAppendComment";
            myControlEntity1.Text         = "Append Comment (no slashes needed):";
            myControlEntity1.RowNumber    = 2;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtAppendComment";
            myControlEntity1.Text         = "";
            myControlEntity1.RowNumber    = 2;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.CheckBox;
            myControlEntity1.ID           = "chkCtrlKey";
            myControlEntity1.Text         = "Is Control Key Pressed?";
            myControlEntity1.RowNumber    = 4;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            if (myActions.GetValueByKey("ScriptGeneratorCtrlKey") == "True")
            {
                myControlEntity1.Checked = true;
            }
            else
            {
                myControlEntity1.Checked = false;
            }
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.CheckBox;
            myControlEntity1.ID           = "chkAltKey";
            myControlEntity1.Text         = "Is Alt Key Pressed?";
            myControlEntity1.RowNumber    = 5;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            if (myActions.GetValueByKey("ScriptGeneratorAltKey") == "True")
            {
                myControlEntity1.Checked = true;
            }
            else
            {
                myControlEntity1.Checked = false;
            }
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.CheckBox;
            myControlEntity1.ID           = "chkShiftKey";
            myControlEntity1.Text         = "Is Shift Key Pressed?";
            myControlEntity1.RowNumber    = 6;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            if (myActions.GetValueByKey("ScriptGeneratorShiftKey") == "True")
            {
                myControlEntity1.Checked = true;
            }
            else
            {
                myControlEntity1.Checked = false;
            }
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType     = ControlType.Label;
            myControlEntity1.ID              = "lblVSShortCutKeys";
            myControlEntity1.Text            = "Visual Studio Shortcut Keys:";
            myControlEntity1.RowNumber       = 7;
            myControlEntity1.ColumnNumber    = 0;
            myControlEntity1.ColumnSpan      = 2;
            myControlEntity1.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
            myControlEntity1.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);

            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnMinimizeVisualStudio";
            myControlEntity1.Text         = "Minimize Visual Studio";
            myControlEntity1.RowNumber    = 8;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnMaximizeVisualStudio";
            myControlEntity1.Text         = "Maximize Visual Studio";
            myControlEntity1.RowNumber    = 9;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType     = ControlType.Label;
            myControlEntity1.ID              = "lblIEShortCutKeys";
            myControlEntity1.Text            = "Internet Explorer Shortcut Keys:";
            myControlEntity1.RowNumber       = 10;
            myControlEntity1.ColumnNumber    = 0;
            myControlEntity1.ColumnSpan      = 2;
            myControlEntity1.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
            myControlEntity1.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEAltD";
            myControlEntity1.Text         = "Go To Address Bar and select it Alt-D";
            myControlEntity1.RowNumber    = 11;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEAltEnter";
            myControlEntity1.Text         = "Alt enter while in address bar opens new tab";
            myControlEntity1.RowNumber    = 12;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEF6";
            myControlEntity1.Text         = "F6 selects address bar in IE";
            myControlEntity1.RowNumber    = 13;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEMax";
            myControlEntity1.Text         = "Maximize IE";
            myControlEntity1.RowNumber    = 14;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIECloseCurrentTab";
            myControlEntity1.Text         = "Close Current Tab";
            myControlEntity1.RowNumber    = 15;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEGoToTopOfPage";
            myControlEntity1.Text         = "HOME goes to top of page";
            myControlEntity1.RowNumber    = 16;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnIEClose";
            myControlEntity1.Text         = "Close IE";
            myControlEntity1.RowNumber    = 17;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());


            //          internet explorer
            //myActions.TypeText("%(d)", 2500); // go to address bar in internet explorer
            //          myActions.TypeText("%({ENTER})", 2500);  // Alt enter while in address bar opens new tab
            //          myActions.TypeText("{F6}", 2500); // selects address bar in internet explorer
            //          myActions.TypeText("%(\" \")", 500); // maximize internet explorer
            //          myActions.TypeText("x", 500);
            //          myActions.TypeText("^(w)", 500); // close the current tab
            //          myActions.TypeText("{HOME}", 500); // go to top of web page
            //          myActions.TypeText("%(f)", 1000);  // close internet explorer
            //          myActions.TypeText("x", 1000);  // close internet explorer

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType     = ControlType.Label;
            myControlEntity1.ID              = "lblEditingShortCutKeys";
            myControlEntity1.Text            = "Editing Shortcut Keys:";
            myControlEntity1.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
            myControlEntity1.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
            myControlEntity1.RowNumber       = 3;
            myControlEntity1.ColumnNumber    = 2;
            myControlEntity1.ColumnSpan      = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnCopy";
            myControlEntity1.Text         = "Ctrl-C Copy";
            myControlEntity1.RowNumber    = 4;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnCut";
            myControlEntity1.Text         = "Ctrl-x Cut";
            myControlEntity1.RowNumber    = 5;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnSelectAll";
            myControlEntity1.Text         = "Ctrl-a Select All";
            myControlEntity1.RowNumber    = 6;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnPaste";
            myControlEntity1.Text         = "Ctrl-v Paste";
            myControlEntity1.RowNumber    = 7;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType     = ControlType.Label;
            myControlEntity1.ID              = "lblSpecialKeys";
            myControlEntity1.Text            = "Special Keys:";
            myControlEntity1.BackgroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.Red.R, System.Drawing.Color.Red.G, System.Drawing.Color.Red.B);
            myControlEntity1.ForegroundColor = System.Windows.Media.Color.FromRgb(System.Drawing.Color.White.R, System.Drawing.Color.White.G, System.Drawing.Color.White.B);
            myControlEntity1.RowNumber       = 8;
            myControlEntity1.ColumnNumber    = 2;
            myControlEntity1.ColumnSpan      = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnDelete";
            myControlEntity1.Text         = "{DELETE}";
            myControlEntity1.RowNumber    = 9;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnDown";
            myControlEntity1.Text         = "{DOWN}";
            myControlEntity1.RowNumber    = 10;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnEnd";
            myControlEntity1.Text         = "{END}";
            myControlEntity1.RowNumber    = 11;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnEnter";
            myControlEntity1.Text         = "{ENTER}";
            myControlEntity1.RowNumber    = 12;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnEscape";
            myControlEntity1.Text         = "{ESCAPE}";
            myControlEntity1.RowNumber    = 13;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnFxx";
            myControlEntity1.Text         = "{Fxx}";
            myControlEntity1.RowNumber    = 14;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnHome";
            myControlEntity1.Text         = "{HOME}";
            myControlEntity1.RowNumber    = 15;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnLeft";
            myControlEntity1.Text         = "{LEFT}";
            myControlEntity1.RowNumber    = 16;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnPGDN";
            myControlEntity1.Text         = "{PGDN}";
            myControlEntity1.RowNumber    = 17;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnPGUP";
            myControlEntity1.Text         = "{PGUP}";
            myControlEntity1.RowNumber    = 18;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnRight";
            myControlEntity1.Text         = "{RIGHT}";
            myControlEntity1.RowNumber    = 19;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnSpace";
            myControlEntity1.Text         = "{SPACE}";
            myControlEntity1.RowNumber    = 20;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnTAB";
            myControlEntity1.Text         = "{TAB}";
            myControlEntity1.RowNumber    = 21;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Button;
            myControlEntity1.ID           = "btnUP";
            myControlEntity1.Text         = "{UP}";
            myControlEntity1.RowNumber    = 22;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSpecialKeysModifier";
            myControlEntity1.Text         = "Special Keys Repeat Count/Func Modifier:";
            myControlEntity1.RowNumber    = 23;
            myControlEntity1.ColumnNumber = 0;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSpecialKeysModifier";
            myControlEntity1.Text         = "";
            myControlEntity1.RowNumber    = 23;
            myControlEntity1.ColumnNumber = 2;
            myControlEntity1.ColumnSpan   = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr = 23;

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 750, 900, intWindowTop, intWindowLeft);


            if (strButtonPressed == "btnCancel")
            {
                goto myExit;
            }

            if (strButtonPressed == "btnMinimizeVisualStudio")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%(\" \"n)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "Minimize Visual Studio";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnMaximizeVisualStudio")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%(f)x";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "Maximize Visual Studio";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIEAltD")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%(d)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "Go to IE address bar and select it";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }


            if (strButtonPressed == "btnIEAltEnter")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%({ENTER})";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "Alt enter while in address bar opens new tab";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIEF6")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{F6}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "F6 is another way to highlight address bar in IE";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIEMax")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%(\" \")";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "maximize internet explorer";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIECloseCurrentTab")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "^(w)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "close the current tab";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIEGoToTopOfPage")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{HOME}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "go to top of web page";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnIEClose")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "%(f)x";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "close internet explorer";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnCopy")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "^(c)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "copy";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnCut")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "^(x)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "cut";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnSelectAll")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "^(a)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "select all";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnPaste")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "^(v)";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "paste";
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            string txtSpecialKeysModifier = myListControlEntity1.Find(x => x.ID == "txtSpecialKeysModifier").Text;

            if (strButtonPressed == "btnFxx")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{F" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (txtSpecialKeysModifier.Length > 0)
            {
                txtSpecialKeysModifier = " " + txtSpecialKeysModifier;
            }

            if (strButtonPressed == "btnDelete")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{DELETE" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "delete";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnDown")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{DOWN" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "down";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnEnd")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{END" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "end";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnEnter")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{ENTER" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "enter";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnEscape")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{ESCAPE" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "escape";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnHome")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{HOME" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "home";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnLeft")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{LEFT" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "left";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnPGDN")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{PGDN" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "page down";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnPGUP")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{PGUP" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "page up";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnRight")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{RIGHT" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "right";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnSpace")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{SPACE" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "space";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnTAB")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{TAB" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "tab";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }

            if (strButtonPressed == "btnUP")
            {
                myListControlEntity1.Find(x => x.ID == "txtTextToType").Text    = "{UP" + txtSpecialKeysModifier + "}";
                myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text = "up";

                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 800, 900, intWindowTop, intWindowLeft);
            }



            //if (strButtonPressed == "btnOkay") {
            //  strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 650, 800, 100, 850);
            //  goto DisplayWindowAgain;
            //}
            string strTextToType         = myListControlEntity1.Find(x => x.ID == "txtTextToType").Text;
            string strAppendComment      = myListControlEntity1.Find(x => x.ID == "txtAppendComment").Text;
            string strMillisecondsToWait = myListControlEntity1.Find(x => x.ID == "txtMillisecondsToWait").Text;
            bool   boolCtrlKey           = myListControlEntity1.Find(x => x.ID == "chkCtrlKey").Checked;
            bool   boolAltKey            = myListControlEntity1.Find(x => x.ID == "chkAltKey").Checked;
            bool   boolShiftKey          = myListControlEntity1.Find(x => x.ID == "chkShiftKey").Checked;

            myActions.SetValueByKey("ScriptGeneratorDefaultMilliseconds", strMillisecondsToWait);
            myActions.SetValueByKey("ScriptGeneratorCtrlKey", boolCtrlKey.ToString());
            myActions.SetValueByKey("ScriptGeneratorAltKey", boolAltKey.ToString());
            myActions.SetValueByKey("ScriptGeneratorShiftKey", boolShiftKey.ToString());

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            if (strAppendComment.Length > 0)
            {
                strAppendComment = " // " + strAppendComment;
            }
            string strGeneratedLine = "";
            //   string strType = myListControlEntity1.Find(x => x.ID == "cbxType").SelectedValue;
            bool boolVariable = false;

            if (strTextToType.Trim() == "")
            {
                boolVariable = true;
            }
            string strTextToTypeToUse = "";

            strTextToTypeToUse = "\"" + strTextToType.Trim() + "\"";

            if (!boolVariable && !boolCtrlKey && !boolAltKey && !boolShiftKey)
            {
                if (strAppendComment == " // Maximize Visual Studio" && strTextToType == "%(f)x")
                {
                    strGeneratedLine  = "myActions.TypeText(\"%(f)\"," + strMillisecondsToWait + ");" + strAppendComment;
                    strGeneratedLine += System.Environment.NewLine + "myActions.TypeText(\"x\"," + strMillisecondsToWait + ");";
                    myActions.PutEntityInClipboard(strGeneratedLine);
                    myActions.MessageBoxShow(strGeneratedLine);
                }
                else if (strAppendComment == " // maximize internet explorer" && strTextToType == "%(\" \")")
                {
                    strGeneratedLine  = "myActions.TypeText(\"%(\\\" \\\")\"," + strMillisecondsToWait + ");" + strAppendComment;
                    strGeneratedLine += System.Environment.NewLine + "myActions.TypeText(\"x\"," + strMillisecondsToWait + ");";
                    myActions.PutEntityInClipboard(strGeneratedLine);
                    myActions.MessageBoxShow(strGeneratedLine);
                }
                else if (strAppendComment == " // close internet explorer" && strTextToType == "%(f)x")
                {
                    strGeneratedLine  = "myActions.TypeText(\"%(f)," + strMillisecondsToWait + ");" + strAppendComment;
                    strGeneratedLine += System.Environment.NewLine + "myActions.TypeText(\"x\"," + strMillisecondsToWait + ");";
                    myActions.PutEntityInClipboard(strGeneratedLine);
                    myActions.MessageBoxShow(strGeneratedLine);
                }
                else
                {
                    strGeneratedLine = "myActions.TypeText(" + strTextToTypeToUse + "," + strMillisecondsToWait + ");" + strAppendComment;
                    myActions.PutEntityInClipboard(strGeneratedLine);
                    myActions.MessageBoxShow(strGeneratedLine);
                }
            }
            if (boolVariable && !boolCtrlKey && !boolAltKey && !boolShiftKey)
            {
                strGeneratedLine = "myActions.TypeText(" + strTextToTypeToUse + "," + strMillisecondsToWait + ");" + strAppendComment;
                myActions.PutEntityInClipboard(strGeneratedLine);
                myActions.MessageBoxShow(strGeneratedLine);
            }
            if (boolCtrlKey && !boolVariable)
            {
                strGeneratedLine = "myActions.TypeText(\"^(" + strTextToType + ")\"," + strMillisecondsToWait + ");" + strAppendComment;
                myActions.PutEntityInClipboard(strGeneratedLine);
                myActions.MessageBoxShow(strGeneratedLine);
            }
            if (boolCtrlKey && boolVariable)
            {
                myActions.MessageBoxShow("Control Key and Variable is not valid");
            }
            if (boolAltKey && !boolVariable)
            {
                strGeneratedLine = "myActions.TypeText(\"%(" + strTextToType + ")\"," + strMillisecondsToWait + ");" + strAppendComment;
                myActions.PutEntityInClipboard(strGeneratedLine);
                myActions.MessageBoxShow(strGeneratedLine);
            }
            if (boolAltKey && boolVariable)
            {
                myActions.MessageBoxShow("Alt Key and Variable is not valid");
            }

            if (boolShiftKey && !boolVariable)
            {
                strGeneratedLine = "myActions.TypeText(\"+(" + strTextToType + ")\"," + strMillisecondsToWait + ");" + strAppendComment;


                myActions.PutEntityInClipboard(strGeneratedLine);
                myActions.MessageBoxShow(strGeneratedLine);
            }
            if (boolShiftKey && boolVariable)
            {
                myActions.MessageBoxShow("Shift Key and Variable is not valid");
            }

            if (strGeneratedLine != "")
            {
                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, strGeneratedLine);

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 16
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("RetrieveClips"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intRowCtr           = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lblListofClips";
            myControlEntity.Text         = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblClips";
            myControlEntity.Text         = "Clips";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp.Clear();
            string root = @"C:\Data\Clips";

            string[] subdirectoryEntries = Directory.GetDirectories(root);
            cbp.Add(new ComboBoxPair("--select clip--", "--select clip--"));
            foreach (var item in subdirectoryEntries)

            {
                string itemx = item.Replace(root + @"\", "");
                cbp.Add(new ComboBoxPair(itemx, itemx));
            }

            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "--select clip--";
            myControlEntity.ID           = "cbxClips";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ToolTipx     = "Select clip to put in clipboard";
            myControlEntity.DDLName      = "";
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string strClips  = myListControlEntity.Find(x => x.ID == "cbxClips").SelectedValue;
            string fileName1 = @"C:\Data\Clips\" + strClips;

            ClipboardHelper.Deserialize(fileName1);
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 17
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("AddNewFieldToIEA"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            myActions.WindowShape("RedBox", "", "Step 1", "Add the field to roaming ", 30, 30);
            myActions.WindowShape("RedBox", "", "Step 2", "Add the field to FileView  ", 30, 30);
            myActions.WindowShape("RedBox", "", "Step 3", "Add the column to ExplorerView ", 30, 30);


            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            if (myWebSite == "http://www.google.com")
            {
                myActions.TypeText("%(d)", 500);
                myActions.TypeText("{ESC}", 500);
                myActions.TypeText("{F6}", 500);
                myActions.TypeText("{TAB}", 500);
                myActions.TypeText("{TAB 2}", 500);
                myActions.TypeText("{ESC}", 500);
            }
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"");
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgPatch2015_08_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgPatch2015_08.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 30;
            myImage.RelativeY = 10;


            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of " + myImage.ImageFile);
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.RightClick(myArray);

            myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            myActions.Run(@"C:\Program Files\Microsoft Office\Office15\EXCEL.EXE", @"C:\SVNStats\SVNStats.xlsx");
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 18
0
        public MainWindow()
        {
            int  delay = 500;
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            // Create a timer and set a two millisecond interval.

            aTimer.Interval = 2;

            // Alternate method: create a Timer with an interval argument to the constructor.
            //aTimer = new System.Timers.Timer(2000);

            // Create a timer with a two millisecond interval.
            aTimer = new System.Timers.Timer(2);

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed += OnTimedEvent;

            // Have the timer fire repeated events (true is the default)
            aTimer.AutoReset = true;

            // Start the timer
            aTimer.Enabled  = true;
            spaceBarPressed = false;

            window.Show();

            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("ExecuteWithBreakpointTrace"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }

            myListControlEntity = new List <ControlEntity>();
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lbl";
            myControlEntity.Text         = "ExecuteWithBreakpointTrace";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Label;
            myControlEntity.ID          = "lbl";
            myControlEntity.Text        = "" +
                                          "1. Click on visual studio to debug \r\n";
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 272;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Label;
            myControlEntity.ID          = "lbl";
            myControlEntity.Text        = "" +
                                          "2. Close this window to start debugging \r\n";
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 312;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Label;
            myControlEntity.ID          = "lbl";
            myControlEntity.Text        = "" +
                                          "3. PRESS Ctrl-Space to stop debugger \r\n";
            myControlEntity.ToolTipx     = "";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.Width        = 312;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());
            strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 624, 0, 0);
            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            // TODO: In IdealAutomateCore, create another PutAll override that does not ask if you want an alternative image when it cannot find image
            string firstLine         = "";
            string currentLine       = "";
            string currentLineNumber = "";
            string firstFileName     = "";
            string currFileName      = "";
            string firstLineNumber   = "";

            myActions.TypeText("{F11}", 1000); // compile program and go to first breakpoint
            int intCtr = 0;

TryToFindYellowArrow:
            intCtr++;
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgYellowArrow.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgYellowArrow.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 1;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myImage.Tolerance = 60;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0 && intCtr < 50)
            {
                goto TryToFindYellowArrow;
            }
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of YellowArrow");
            }
            else
            {
                // myActions.MessageBoxShow("Found Yellow Arrow");
            }
            myActions.TypeText("^(c)", delay);
            currentLine = myActions.PutClipboardInEntity();
            firstLine   = currentLine;
            LineOfCode myLine = new LineOfCode();

            myLine.TextOfCode = currentLine;

            // get line number
            myActions.TypeText("^(g)", delay);
            myActions.TypeText("^(a)", delay);
            myActions.TypeText("^(c)", delay);
            currentLineNumber = myActions.PutClipboardInEntity();
            firstLineNumber   = currentLineNumber;
            myLine.LineNumber = currentLineNumber;
            myActions.TypeText("{ESCAPE}", delay);

            // get filename
            myActions.TypeText("%(f)", delay);
            myActions.TypeText("a", delay);
            myActions.TypeText("^(c)", delay);
            currFileName    = myActions.PutClipboardInEntity();
            myLine.FileName = currFileName;
            firstFileName   = currFileName;
            myActions.TypeText("{ESCAPE}", delay);

            // add the line to list
            listExecutedCode.Add(myLine);
            LineOfCode prevLine = myLine;

GetNextLine:
            if (spaceBarPressed)
            {
                goto EndOfExecution;
            }
            // get next line
            myActions.TypeText("{F11}", delay); // next breakpoint
            myActions.TypeText("^(c)", delay);
            currentLine       = myActions.PutClipboardInEntity();
            myLine            = new LineOfCode();
            myLine.TextOfCode = currentLine;

            // get line number
            myActions.TypeText("^(g)", delay);
            myActions.TypeText("^(a)", delay);
            myActions.TypeText("^(c)", delay);
            currentLineNumber = myActions.PutClipboardInEntity();
            firstLineNumber   = currentLineNumber;
            myLine.LineNumber = currentLineNumber;
            myActions.TypeText("{ESCAPE}", delay);

            // get filename
            myActions.TypeText("%(f)", delay);
            myActions.TypeText("a", delay);
            myActions.TypeText("^(c)", delay);
            currFileName    = myActions.PutClipboardInEntity();
            myLine.FileName = currFileName;
            firstFileName   = currFileName;
            myActions.TypeText("{ESCAPE}", delay);

            // add the line to list
            listExecutedCode.Add(myLine);

            if (myLine != prevLine)
            {
                prevLine = myLine;
                goto GetNextLine;
            }
EndOfExecution:
            myActions.MessageBoxShow("Successfully Reached End of Execution");

            string strOutFile = @"C:\Data\ExecutedCode.txt";

            if (File.Exists(strOutFile))
            {
                File.Delete(strOutFile);
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile))
            {
                // Write list to text file so I can look at it
                foreach (LineOfCode item in listExecutedCode)
                {
                    file.WriteLine(item.FileName + " " + item.LineNumber + " " + item.TextOfCode);
                }
            }


            string strExecutable = @"C:\Windows\system32\notepad.exe";

            myActions.RunSync(strExecutable, strOutFile);


            // We found output completed and now want to copy the results
            // to notepad


myExit:
            aTimer.Enabled = false;
            aTimer.Stop();
            aTimer.Close();
            myActions.Sleep(1000);
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 19
0
        public MainWindow()
        {
            IdealAutomate.Core.Methods myActions = new Methods();
            try
            {
                var window = new Window() //make sure the window is invisible
                {
                    Width         = 0,
                    Height        = 0,
                    Left          = -2000,
                    WindowStyle   = WindowStyle.None,
                    ShowInTaskbar = false,
                    ShowActivated = false,
                };
                window.Show();

                InitializeComponent();
                myActions.DebugMode = true;
                string myBigSqlString    = "";
                string junk              = "";
                string strScriptName     = "IdealSqlTracer";
                string settingsDirectory = GetAppDirectoryForScript(strScriptName);
                string fileName;
                string strSavedDomainName;
                fileName           = "DomainName.txt";
                strSavedDomainName = ReadValueFromAppDataFile(settingsDirectory, fileName);
                if (strSavedDomainName == "")
                {
                    strSavedDomainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
                }

                List <ControlEntity> myListControlEntity = new List <ControlEntity>();
                ControlEntity        myControlEntity     = new ControlEntity();
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.Heading;
                myControlEntity.Text        = "Domain Name";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "myLabel2";
                myControlEntity.Text         = "Enter Domain Name";
                myControlEntity.RowNumber    = 0;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.TextBox;
                myControlEntity.ID           = "myDomainName";
                myControlEntity.Text         = strSavedDomainName;
                myControlEntity.ToolTipx     = "To find Windows Domain, Open the Control Panel, click the System and Security " + System.Environment.NewLine + "category, and click System. Look under “Computer name, " + System.Environment.NewLine + "domain and workgroup settings” here. If you see “Domain”:" + System.Environment.NewLine + "followed by the name of a domain, your computer is joined to a domain." + System.Environment.NewLine + "Most computers running at home do not have a domain as they do" + System.Environment.NewLine + "not use Active Directory..";
                myControlEntity.RowNumber    = 0;
                myControlEntity.ColumnNumber = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "mylabel";
                myControlEntity.ColumnSpan   = 2;
                myControlEntity.Text         = "(Leave domain name blank if not using server in Active Directory)";
                myControlEntity.RowNumber    = 1;
                myControlEntity.ColumnNumber = 0;
                myControlEntity.Checked      = true;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

                if (strButtonPressed == "btnCancel")
                {
                    myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                    goto myExitApplication;
                }

                string strDomainName = myListControlEntity.Find(x => x.ID == "myDomainName").Text;

                fileName = "DomainName.txt";
                WriteValueToAppDirectoryFile(settingsDirectory, fileName, strDomainName);

                ArrayList     myServers        = new ArrayList();
                List <string> servers          = new List <string>();
                List <string> listLocalServers = new List <string>();

                // Get servers from the registry (if any)
                try
                {
                    RegistryKey key = RegistryKey.OpenBaseKey(
                        Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
                    key = key.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
                    object installedInstances = null;
                    if (key != null)
                    {
                        installedInstances = key.GetValue("InstalledInstances");
                    }
                    List <string> instances = null;
                    if (installedInstances != null)
                    {
                        instances = ((string[])installedInstances).ToList();
                    }
                    if (System.Environment.Is64BitOperatingSystem)
                    {
                        /* The above registry check gets routed to the syswow portion of
                         * the registry because we're running in a 32-bit app. Need
                         * to get the 64-bit registry value(s) */
                        key = RegistryKey.OpenBaseKey(
                            Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
                        key = key.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
                        installedInstances = null;
                        if (key != null)
                        {
                            installedInstances = key.GetValue("InstalledInstances");
                        }
                        string[] moreInstances = null;
                        if (installedInstances != null)
                        {
                            moreInstances = (string[])installedInstances;
                            if (instances == null)
                            {
                                instances = moreInstances.ToList();
                            }
                            else
                            {
                                instances.AddRange(moreInstances);
                            }
                        }
                    }

                    if (instances != null)
                    {
                        foreach (string item in instances)
                        {
                            string name = System.Environment.MachineName;
                            if (item != "MSSQLSERVER")
                            {
                                name += @"\" + item;
                            }
                            if (!myServers.Contains(name.ToUpper()))
                            {
                                myServers.Add(name.ToUpper());
                                listLocalServers.Add(name.ToUpper());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MessageBox.Show(ex.StackTrace);
                    MessageBox.Show(ex.InnerException.ToString());
                }
                try
                {
                    string myldap = FriendlyDomainToLdapDomain(strDomainName);

                    string         distinguishedName = string.Empty;
                    string         connectionPrefix  = "LDAP://" + myldap;
                    DirectoryEntry entry             = new DirectoryEntry(connectionPrefix);

                    DirectorySearcher mySearcher = new DirectorySearcher(entry);
                    mySearcher.Filter   = "(&(objectClass=Computer)(operatingSystem=Windows Server*) (!cn=wde*))";
                    mySearcher.PageSize = 1000;
                    mySearcher.PropertiesToLoad.Add("name");

                    SearchResultCollection result = mySearcher.FindAll();
                    if (result != null)
                    {
                        foreach (SearchResult item in result)
                        {
                            // Get the properties for 'mySearchResult'.
                            ResultPropertyCollection myResultPropColl;

                            myResultPropColl = item.Properties;

                            foreach (Object myCollection in myResultPropColl["name"])
                            {
                                myServers.Add(myCollection.ToString());
                            }
                        }
                    }

                    entry.Close();
                    entry.Dispose();
                    mySearcher.Dispose();
                }
                catch (Exception)
                {
                    // do not show exception because they may not be using active directory
                }
                myServers.Sort();
                fileName = "Servers.txt";
                WriteArrayListToAppDirectoryFile(settingsDirectory, fileName, myServers);
                if (myServers.Count < 1)
                {
                    MessageBox.Show("No servers found on local computer or network - aborting");
                    goto myExitApplication;
                }

                myListControlEntity = new List <ControlEntity>();
                myControlEntity     = new ControlEntity();
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.Heading;
                myControlEntity.Text        = "Select Server";
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "myLabel2";
                myControlEntity.Text         = "Select Server";
                myControlEntity.RowNumber    = 0;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.ComboBox;
                myControlEntity.ID          = "myComboBox";
                myControlEntity.Text        = "";
                List <ComboBoxPair> cbp = new List <ComboBoxPair>();
                fileName  = "Servers.txt";
                myServers = ReadAppDirectoryFileToArrayList(settingsDirectory, fileName);
                foreach (var item in myServers)
                {
                    cbp.Add(new ComboBoxPair(item.ToString(), item.ToString()));
                }
                myControlEntity.ListOfKeyValuePairs = cbp;
                fileName = "ServerSelectedValue.txt";
                myControlEntity.SelectedValue = ReadValueFromAppDataFile(settingsDirectory, fileName);
                myControlEntity.RowNumber     = 0;
                myControlEntity.ColumnNumber  = 1;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());
                int intRowCtr = 1;

                intRowCtr++;
                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType  = ControlType.Label;
                myControlEntity.ID           = "lblAlternateServer";
                myControlEntity.Text         = "Alternate Server";
                myControlEntity.RowNumber    = intRowCtr;
                myControlEntity.ColumnNumber = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());

                myControlEntity.ControlEntitySetDefaults();
                myControlEntity.ControlType = ControlType.TextBox;
                myControlEntity.ID          = "txtAlternateServer";
                fileName                     = "txtAlternateServer.txt";
                myControlEntity.Text         = ReadValueFromAppDataFile(settingsDirectory, fileName);
                myControlEntity.ToolTipx     = "If server was not in dropdown, you can type it here; otherwise, leave blank";
                myControlEntity.RowNumber    = intRowCtr;
                myControlEntity.ColumnNumber = 1;
                myControlEntity.ColumnSpan   = 0;
                myListControlEntity.Add(myControlEntity.CreateControlEntity());


                // ===========================================================================
                strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

                if (strButtonPressed == "btnCancel")
                {
                    myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                    goto myExitApplication;
                }


                string strServerName = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;
                fileName = "ServerSelectedValue.txt";
                WriteValueToAppDirectoryFile(settingsDirectory, fileName, strServerName);
                string strAlternateServer = myListControlEntity.Find(x => x.ID == "txtAlternateServer").Text;
                fileName = "txtAlternateServer.txt";
                WriteValueToAppDirectoryFile(settingsDirectory, fileName, strAlternateServer);
                string myFile = "";
                if (strAlternateServer != "")
                {
                    myActions.PutEntityInClipboard(strAlternateServer);
                    myFile = strAlternateServer;
                }
                else
                {
                    myActions.PutEntityInClipboard(strServerName);
                    myFile = strServerName;
                }
                myActions.MessageBoxShow("Server name " + myFile + " has been copied to clipboard to help you fill out server name");
            } catch (Exception ex)
            {
                myActions.MessageBoxShow(ex.Message);
            }
            string connectionString = PromptForConnectionString("");

            myActions.PutEntityInClipboard(connectionString);
            myActions.MessageBoxShow("ConnectionString " + connectionString + " has been copied to clipboard");

myExitApplication:
            Application.Current.Shutdown();
        }
Ejemplo n.º 20
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("IEGoToURL"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayIEGoToURLWindow:
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp = new List <ComboBoxPair>();

            // Row 0 is heading that says:
            // IE Go To URL
            intRowCtr = 0;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblIEGoToURL";
            myControlEntity1.Text         = "IE Go To URL";
            myControlEntity1.Width        = 300;
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            // Row 1 has label Syntax and textbox that contains syntax
            // The syntax is hard-coded inline
            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSyntax2";
            myControlEntity1.Text         = "myActions.IEGoToURL([[Website URL]], [[Use New Tab]]);";
            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            // Row 2 has label Input
            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblInput";
            myControlEntity1.Text         = "Input:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            // Row 3 has label Website URL
            // and textbox that contains Website URL
            // The value for Website URL comes from roaming folder for script
            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblWebsiteURL";
            myControlEntity1.Text         = "Website URL:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtWebsiteURL";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorWebsiteURLx");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());


            // Row 4 has label Use New Tab
            // and textbox that contains UseNewTab
            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblUseNewTab";
            myControlEntity1.Text         = "Use New Tab:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("true", "true"));
            cbp.Add(new ComboBoxPair("false", "false"));
            myControlEntity1.ListOfKeyValuePairs = cbp;
            myControlEntity1.SelectedValue       = myControlEntity1.SelectedValue = myActions.GetValueByKey("ScriptGeneratorUseNewTab");
            if (myControlEntity1.SelectedValue == null)
            {
                myControlEntity1.SelectedValue = "--Select Item ---";
            }
            myControlEntity1.ID           = "cbxUseNewTab";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblUseNewTab";
            myControlEntity1.Text         = "(Optional)";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 2;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);
            // Display input dialog
            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 400, 700, intWindowTop, intWindowLeft);
            // Get Values from input dialog and save to roaming

            string strWebsiteURLx = myListControlEntity1.Find(x => x.ID == "txtWebsiteURL").Text;
            string strUseNewTab   = myListControlEntity1.Find(x => x.ID == "cbxUseNewTab").SelectedValue;

            myActions.SetValueByKey("ScriptGeneratorWebsiteURLx", strWebsiteURLx);
            myActions.SetValueByKey("ScriptGeneratorUseNewTab", strUseNewTab);

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            // if okay button pressed, validate inputs; place inputs into syntax; put generated
            // code into clipboard and display generated code
            if (strButtonPressed == "btnOkay")
            {
                string strWebsiteURLToUse = "";

                strWebsiteURLToUse = "\"" + strWebsiteURLx.Trim() + "\"";
                if (strUseNewTab == "")
                {
                    strUseNewTab = "false";
                }

                string strGeneratedLinex = "";

                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);



                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, strWebsiteURLToUse, strUseNewTab);

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============

                strGeneratedLinex = "myActions.IEGoToURL(myActions, " + strWebsiteURLToUse + ", " + strUseNewTab + ");";

                myActions.PutEntityInClipboard(strGeneratedLinex);
                myActions.MessageBoxShow(strGeneratedLinex + Environment.NewLine + Environment.NewLine + "The generated text has been put into your clipboard");
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 21
0
        public SMSPage()
        {
            bool boolRunningFromHome = false;

//      var window = new Window() //make sure the window is invisible
//{
//        Width = 0,
//        Height = 0,
//        Left = -2000,
//        WindowStyle = WindowStyle.None,
//        ShowInTaskbar = false,
//        ShowActivated = false,
//      };
//      window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            //    this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("SMSParameters"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intRowCtr           = 0;
            ControlEntity        myControlEntity     = new ControlEntity();
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();
            List <ComboBoxPair>  cbp = new List <ComboBoxPair>();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Heading;
            myControlEntity.ID           = "lbl";
            myControlEntity.Text         = "SMS Parameters";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblUserId";
            myControlEntity.Text         = "UserId";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtUserId";
            myControlEntity.Text         = myActions.GetValueByKey("UserId");;
            myControlEntity.ToolTipx     = "UserId or email address for email acct";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblPassword";
            myControlEntity.Text         = "Password";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtPassword";
            myControlEntity.Text         = myActions.GetValueByKey("Password");;
            myControlEntity.ToolTipx     = "Password for email acct";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblClientHost";
            myControlEntity.Text         = "ClientHost";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtClientHost";
            myControlEntity.Text         = myActions.GetValueByKey("ClientHost");;
            myControlEntity.ToolTipx     = "ClientHost for email acct - example smtp.gmail.com";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblcarriersmsemailsuffix";
            myControlEntity.Text         = "carrier sms email suffix";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myControlEntity.ColumnSpan   = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("@messaging.sprintpcs.com", "@messaging.sprintpcs.com"));
            cbp.Add(new ComboBoxPair("@itelemigcelular.com.br", "@itelemigcelular.com.br"));
            cbp.Add(new ComboBoxPair("@message.alltel.com", "@message.alltel.com"));
            cbp.Add(new ComboBoxPair("@message.pioneerenidcellular.com", "@message.pioneerenidcellular.com"));
            cbp.Add(new ComboBoxPair("@messaging.cellone-sf.com", "@messaging.cellone-sf.com"));
            cbp.Add(new ComboBoxPair("@messaging.centurytel.net", "@messaging.centurytel.net"));
            cbp.Add(new ComboBoxPair("@messaging.sprintpcs.com", "@messaging.sprintpcs.com"));
            cbp.Add(new ComboBoxPair("@mobile.att.net", "@mobile.att.net"));
            cbp.Add(new ComboBoxPair("@mobile.cell1se.com", "@mobile.cell1se.com"));
            cbp.Add(new ComboBoxPair("@mobile.celloneusa.com", "@mobile.celloneusa.com"));
            cbp.Add(new ComboBoxPair("@mobile.dobson.net", "@mobile.dobson.net"));
            cbp.Add(new ComboBoxPair("@mobile.mycingular.com", "@mobile.mycingular.com"));
            cbp.Add(new ComboBoxPair("@mobile.mycingular.net", "@mobile.mycingular.net"));
            cbp.Add(new ComboBoxPair("@mobile.surewest.com", "@mobile.surewest.com"));
            cbp.Add(new ComboBoxPair("@msg.acsalaska.com", "@msg.acsalaska.com"));
            cbp.Add(new ComboBoxPair("@msg.clearnet.com", "@msg.clearnet.com"));
            cbp.Add(new ComboBoxPair("@msg.mactel.com", "@msg.mactel.com"));
            cbp.Add(new ComboBoxPair("@msg.myvzw.com", "@msg.myvzw.com"));
            cbp.Add(new ComboBoxPair("@msg.telus.com", "@msg.telus.com"));
            cbp.Add(new ComboBoxPair("@mycellular.com", "@mycellular.com"));
            cbp.Add(new ComboBoxPair("@mycingular.com", "@mycingular.com"));
            cbp.Add(new ComboBoxPair("@mycingular.net", "@mycingular.net"));
            cbp.Add(new ComboBoxPair("@mycingular.textmsg.com", "@mycingular.textmsg.com"));
            cbp.Add(new ComboBoxPair("@o2.net.br", "@o2.net.br"));
            cbp.Add(new ComboBoxPair("@ondefor.com", "@ondefor.com"));
            cbp.Add(new ComboBoxPair("@pcs.rogers.com", "@pcs.rogers.com"));
            cbp.Add(new ComboBoxPair("@personal-net.com.ar", "@personal-net.com.ar"));
            cbp.Add(new ComboBoxPair("@personal.net.py", "@personal.net.py"));
            cbp.Add(new ComboBoxPair("@portafree.com", "@portafree.com"));
            cbp.Add(new ComboBoxPair("@qwest.com", "@qwest.com"));
            cbp.Add(new ComboBoxPair("@qwestmp.com", "@qwestmp.com"));
            cbp.Add(new ComboBoxPair("@sbcemail.com", "@sbcemail.com"));
            cbp.Add(new ComboBoxPair("@sms.bluecell.com", "@sms.bluecell.com"));
            cbp.Add(new ComboBoxPair("@sms.cwjamaica.com", "@sms.cwjamaica.com"));
            cbp.Add(new ComboBoxPair("@sms.edgewireless.com", "@sms.edgewireless.com"));
            cbp.Add(new ComboBoxPair("@sms.hickorytech.com", "@sms.hickorytech.com"));
            cbp.Add(new ComboBoxPair("@sms.net.nz", "@sms.net.nz"));
            cbp.Add(new ComboBoxPair("@sms.pscel.com", "@sms.pscel.com"));
            cbp.Add(new ComboBoxPair("@smsc.vzpacifica.net", "@smsc.vzpacifica.net"));
            cbp.Add(new ComboBoxPair("@speedmemo.com", "@speedmemo.com"));
            cbp.Add(new ComboBoxPair("@suncom1.com", "@suncom1.com"));
            cbp.Add(new ComboBoxPair("@sungram.com", "@sungram.com"));
            cbp.Add(new ComboBoxPair("@telesurf.com.py", "@telesurf.com.py"));
            cbp.Add(new ComboBoxPair("@teletexto.rcp.net.pe", "@teletexto.rcp.net.pe"));
            cbp.Add(new ComboBoxPair("@text.houstoncellular.net", "@text.houstoncellular.net"));
            cbp.Add(new ComboBoxPair("@text.telus.com", "@text.telus.com"));
            cbp.Add(new ComboBoxPair("@timnet.com", "@timnet.com"));
            cbp.Add(new ComboBoxPair("@timnet.com.br", "@timnet.com.br"));
            cbp.Add(new ComboBoxPair("@tms.suncom.com", "@tms.suncom.com"));
            cbp.Add(new ComboBoxPair("@tmomail.net", "@tmomail.net"));
            cbp.Add(new ComboBoxPair("@tsttmobile.co.tt", "@tsttmobile.co.tt"));
            cbp.Add(new ComboBoxPair("@txt.bellmobility.ca", "@txt.bellmobility.ca"));
            cbp.Add(new ComboBoxPair("@typetalk.ruralcellular.com", "@typetalk.ruralcellular.com"));
            cbp.Add(new ComboBoxPair("@unistar.unifon.com.ar", "@unistar.unifon.com.ar"));
            cbp.Add(new ComboBoxPair("@uscc.textmsg.com", "@uscc.textmsg.com"));
            cbp.Add(new ComboBoxPair("@voicestream.net", "@voicestream.net"));
            cbp.Add(new ComboBoxPair("@vtext.com", "@vtext.com"));
            cbp.Add(new ComboBoxPair("@wireless.bellsouth.com", "@wireless.bellsouth.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = myActions.GetValueByKey("cbxcarriersmsemailsuffix");
            myControlEntity.ID           = "cbxcarriersmsemailsuffix";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ToolTipx     = "";
            myControlEntity.DDLName      = "";
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblPhoneComplete";
            myControlEntity.Text         = "Phone Completed";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtPhoneComplete";
            myControlEntity.Text         = myActions.GetValueByKey("PhoneComplete");;
            myControlEntity.ToolTipx     = "Enter phone number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblSubjectComplete";
            myControlEntity.Text         = "Subject Complete";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtSubjectComplete";
            myControlEntity.Text         = myActions.GetValueByKey("SubjectComplete");
            myControlEntity.ToolTipx     = "Enter Subject number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblMessageBodyComplete";
            myControlEntity.Text         = "MessageBody Complete";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtMessageBodyComplete";
            myControlEntity.Text         = myActions.GetValueByKey("MessageBodyComplete");;
            myControlEntity.ToolTipx     = "Enter MessageBody number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblPhoneError";
            myControlEntity.Text         = "Phone Error";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtPhoneError";
            myControlEntity.Text         = myActions.GetValueByKey("PhoneError");;
            myControlEntity.ToolTipx     = "Enter phone number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblSubjectError";
            myControlEntity.Text         = "Subject Error";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtSubjectError";
            myControlEntity.Text         = myActions.GetValueByKey("SubjectError");;
            myControlEntity.ToolTipx     = "Enter Subject number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            intRowCtr++;
            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "lblMessageBodyError";
            myControlEntity.Text         = "MessageBody Error";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "txtMessageBodyError";
            myControlEntity.Text         = myActions.GetValueByKey("MessageBodyError");;
            myControlEntity.ToolTipx     = "Enter MessageBody number to send sms text to; do not use hyphens";
            myControlEntity.RowNumber    = intRowCtr;
            myControlEntity.ColumnNumber = 1;
            myControlEntity.ColumnSpan   = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }


            string strUserId = myListControlEntity.Find(x => x.ID == "txtUserId").Text;

            myActions.SetValueByKey("UserId", strUserId);
            string strPassword = myListControlEntity.Find(x => x.ID == "txtPassword").Text;

            myActions.SetValueByKey("Password", strPassword);
            string strClientHost = myListControlEntity.Find(x => x.ID == "txtClientHost").Text;

            myActions.SetValueByKey("ClientHost", strClientHost);
            string strcarriersmsemailsuffix = myListControlEntity.Find(x => x.ID == "cbxcarriersmsemailsuffix").SelectedValue;

            myActions.SetValueByKey("cbxcarriersmsemailsuffix", strcarriersmsemailsuffix);
            string strPhoneComplete = myListControlEntity.Find(x => x.ID == "txtPhoneComplete").Text;

            myActions.SetValueByKey("PhoneComplete", strPhoneComplete);

            string strSubjectComplete = myListControlEntity.Find(x => x.ID == "txtSubjectComplete").Text;

            myActions.SetValueByKey("SubjectComplete", strSubjectComplete);

            string strMessageBodyComplete = myListControlEntity.Find(x => x.ID == "txtMessageBodyComplete").Text;

            myActions.SetValueByKey("MessageBodyComplete", strMessageBodyComplete);

            string strPhoneError = myListControlEntity.Find(x => x.ID == "txtPhoneError").Text;

            myActions.SetValueByKey("PhoneError", strPhoneError);

            string strSubjectError = myListControlEntity.Find(x => x.ID == "txtSubjectError").Text;

            myActions.SetValueByKey("SubjectError", strSubjectError);

            string strMessageBodyError = myListControlEntity.Find(x => x.ID == "txtMessageBodyError").Text;

            myActions.SetValueByKey("MessageBodyError", strMessageBodyError);


            // goto myExit;
myExit:
            string mystring = "";
            //myActions.ScriptEndedSuccessfullyUpdateStats();
            //Application.Current.Shutdown();
        }
Ejemplo n.º 22
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("TutorialCreateIdealAutomateTemplate"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            myActions.WindowShape("RedBox", "", "Step 1", " If you want to exit the tutorial at any time, just hit the pause key on your computer. \nAfter you have completed the action in a step of the tutorial, hit Okay button to continue to next step ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 2", "You can drag this dialog box around to reposition it. \nTry it now.   ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 3", "In this instance of Visual Studio in the menu bar, Click File/Export Template... ", 200, 200);
            myActions.WindowShape("RedBox", "", "Step 4", "In the pop-up dialog from Visual Studio, make sure radio button for project template is selected ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 5", "Click the Next button ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 6", "In the textbox for Template Name, type IdealAutomateCoreTemplate \n(Do not click the Finish button yet)", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 7", "In the textbox for Description, put whatever you want. \n(Do not click the Finish button yet)", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 8", "In the icon image box, browse to the images folder for this project and select the up green arrow. \n(Do not click the Finish button yet)", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 9", "In the preview image box, browse to the images folder for this project and select the up green arrow.\n(Do not click the Finish button yet) ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 10", "Check the checkbox for Automatically Import into Visual Studio\n(Do not click the Finish button yet) ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 11", "Check the checkbox for Display explorer window\n(Do not click the Finish button yet) ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 12", "Click the finish button ", 0, 0);
            myActions.WindowShape("RedBox", "", "Step 13", "This tutorial is completed. \nNow when you create new projects with Visual Studio, you will be able to select IdealAutomateCore as the template ", 0, 0);


            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity, 300, 500, -1, 0);

            if (strButtonPressed == "btnCancel")
            {
                myActions.MessageBoxShow("Okay button not pressed - Script Cancelled");
                goto myExit;
            }

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"");
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgPatch2015_08_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgPatch2015_08.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 30;
            myImage.RelativeY = 10;


            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of " + myImage.ImageFile);
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.RightClick(myArray);

            myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            myActions.Run(@"C:\Program Files\Microsoft Office\Office15\EXCEL.EXE", @"C:\SVNStats\SVNStats.xlsx");
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 23
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("CleanCDrive"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            myActions.Run(@"C:\WINDOWS\Explorer.EXE", "");
            myActions.Sleep(1000);
            //
            // P R O C E S S   H A S   B E E N   S T A R T E D:  explorer
            //
            myActions.TypeText(@"%(d)", 1500);
            myActions.TypeText(@"This PC", 1500);
            myActions.TypeText(@"{ENTER}", 1500);
            myActions.TypeText(@"Windows (C:)", 1500);
            myActions.TypeText("%{ENTER}", 1500);
            myActions.TypeText(@"%(d)", 1500);
            myActions.WindowShape("RedBox", "", "Disk Cleanup for Windows c:", " When Disk Cleanup for windows c: popup appears, check all items in list EXCEPT downloads. \nIf you do not uncheck downloads, the files in your downloads folder will be deleted. \nClick okay in the popup to clean the checked items on the c drive. ", 0, 0);

            goto myExit;
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel";
            myControlEntity.Text         = "Enter Search Term";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBox";
            myControlEntity.Text         = "Hello World";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabel2";
            myControlEntity.Text         = "Select Website";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.ComboBox;
            myControlEntity.ID          = "myComboBox";
            myControlEntity.Text        = "Hello World";
            List <ComboBoxPair> cbp = new List <ComboBoxPair>();

            cbp.Add(new ComboBoxPair("google", "http://www.google.com"));
            cbp.Add(new ComboBoxPair("yahoo", "http://www.yahoo.com"));
            myControlEntity.ListOfKeyValuePairs = cbp;
            myControlEntity.SelectedValue       = "http://www.yahoo.com";
            myControlEntity.RowNumber           = 1;
            myControlEntity.ColumnNumber        = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.CheckBox;
            myControlEntity.ID           = "myCheckBox";
            myControlEntity.Text         = "Use new tab";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            myActions.WindowMultipleControls(ref myListControlEntity, 400, 500, 0, 0);

            string mySearchTerm = myListControlEntity.Find(x => x.ID == "myTextBox").Text;
            string myWebSite    = myListControlEntity.Find(x => x.ID == "myComboBox").SelectedValue;

            bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked;

            if (boolUseNewTab == true)
            {
                List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore");
                myWindowTitles.RemoveAll(item => item == "");
                if (myWindowTitles.Count > 0)
                {
                    myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
                    myActions.TypeText("%(d)", 1500);       // select address bar
                    myActions.TypeText("{ESC}", 1500);
                    myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab
                    myActions.TypeText("%(d)", 1500);
                    myActions.TypeText(myWebSite, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    myActions.TypeText("{ESC}", 1500);
                }
                else
                {
                    myActions.Run("iexplore", myWebSite);
                }
            }
            else
            {
                myActions.Run("iexplore", myWebSite);
            }

            myActions.Sleep(1000);
            if (myWebSite == "http://www.google.com")
            {
                myActions.TypeText("%(d)", 500);
                myActions.TypeText("{ESC}", 500);
                myActions.TypeText("{F6}", 500);
                myActions.TypeText("{TAB}", 500);
                myActions.TypeText("{TAB 2}", 500);
                myActions.TypeText("{ESC}", 500);
            }
            myActions.TypeText(mySearchTerm, 500);
            myActions.TypeText("{ENTER}", 500);


            goto myExit;
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"C:\SVN");
            myActions.TypeText("%(e)", 500);
            myActions.TypeText("a", 500);
            myActions.TypeText("^({UP 10})", 500);
            myActions.TypeText("^(\" \")", 500);
            myActions.TypeText("+({F10})", 500);
            ImageEntity myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.RunSync(@"C:\Windows\Explorer.EXE", @"");
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgPatch2015_08_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgPatch2015_08.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 30;
            myImage.RelativeY = 10;


            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of " + myImage.ImageFile);
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.RightClick(myArray);

            myImage = new ImageEntity();

            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgSVNUpdate_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgSVNUpdate.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 5;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;

            myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of SVN Update");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myImage = new ImageEntity();
            if (boolRunningFromHome)
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK_Home.PNG";
            }
            else
            {
                myImage.ImageFile = "Images\\imgUpdateLogOK.PNG";
            }
            myImage.Sleep     = 200;
            myImage.Attempts  = 200;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myArray           = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("I could not find image of OK button for update log");
            }
            // We found output completed and now want to copy the results
            // to notepad

            // Highlight the output completed line
            myActions.Sleep(1000);
            myActions.LeftClick(myArray);
            myActions.TypeText("%(f)", 200);
            myActions.TypeText("{UP}", 500);
            myActions.TypeText("{ENTER}", 500);
            myActions.Sleep(1000);
            myActions.Run(@"C:\SVNStats.bat", "");
            string officePath = myActions.GetValueByKeyGlobalRespondWithDialogIfEmpty("OfficePath");

            myActions.Run(System.IO.Path.Combine(officePath, "EXCEL.EXE"), @"C:\SVNStats\SVNStats.xlsx");
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 24
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            myActions.DebugMode = true;
            ImageEntity myImage = new ImageEntity();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("OpenNotepadLineInVS"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            //myImage.ImageFile = "Images\\Ready.PNG";
            //myImage.Sleep = 3500;
            //myImage.Attempts = 2;
            //myImage.RelativeX = 10;
            //myActions.ClickImageIfExists(myImage);
            List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("notepad++");

            myWindowTitles.RemoveAll(item => item == "");
            if (myWindowTitles.Count > 0)
            {
                myActions.ActivateWindowByTitle(myWindowTitles[0], 3);
                myActions.Sleep(1000);
                //int[,] myCursorPosition = myActions.PutCursorPosition();

                //myActions.RightClick(myCursorPosition);
                myActions.TypeText("{RIGHT}", 500);
                myActions.TypeText("{HOME}", 500);
                myActions.TypeText("+({END})", 500);
                myActions.TypeText("^(c)", 500);
                myActions.Sleep(500);
                string strCurrentLine = "";
                RunAsSTAThread(
                    () => {
                    strCurrentLine = myActions.PutClipboardInEntity();
                });
            }
            myWindowTitles = myActions.GetWindowTitlesByProcessName("devenv");
            string myWebSite = "";

TryAgainClip:
            string myOrigEditPlusLine = myActions.PutClipboardInEntity();

            if (myOrigEditPlusLine.Length == 0)
            {
                System.Windows.Forms.DialogResult myResult = myActions.MessageBoxShowWithYesNo("You forgot to put line in clipboard - Put line in clipboard and click yes to continue");
                if (myResult == System.Windows.Forms.DialogResult.Yes)
                {
                    goto TryAgainClip;
                }
                else
                {
                    goto myExit;
                }
            }
            //string myOrigEditPlusLine = strReadLine;
            bool          boolSolutionFileFound = true;
            string        strSolutionName       = "";
            List <string> myBeginDelim          = new List <string>();
            List <string> myEndDelim            = new List <string>();

            myBeginDelim.Add("\"");
            myEndDelim.Add("\"");
            FindDelimitedTextParms delimParms = new FindDelimitedTextParms(myBeginDelim, myEndDelim);

            string myQuote = "\"";

            delimParms.lines[0] = myOrigEditPlusLine;


            myActions.FindDelimitedText(delimParms);
            int intLastSlash = delimParms.strDelimitedTextFound.LastIndexOf('\\');

            if (intLastSlash < 1)
            {
                myActions.MessageBoxShow("Could not find last slash in in EditPlusLine - aborting");
                goto myExit;
            }
            string strPathOnly     = delimParms.strDelimitedTextFound.SubstringBetweenIndexes(0, intLastSlash);
            string strFileNameOnly = delimParms.strDelimitedTextFound.Substring(intLastSlash + 1);

            myBeginDelim.Clear();
            myEndDelim.Clear();
            myBeginDelim.Add("(");
            myEndDelim.Add(",");
            delimParms          = new FindDelimitedTextParms(myBeginDelim, myEndDelim);
            delimParms.lines[0] = myOrigEditPlusLine;
            myActions.FindDelimitedText(delimParms);
            string strLineNumber = delimParms.strDelimitedTextFound;

            //========
            string strFullName             = Path.Combine(strPathOnly, strFileNameOnly);
            string strSolutionFullFileName = "";

            string currentTempName = strFullName;

            while (currentTempName.IndexOf("\\") > -1)
            {
                currentTempName = currentTempName.Substring(0, currentTempName.LastIndexOf("\\"));
                FileInfo fi = new FileInfo(currentTempName);
                if (Directory.Exists(currentTempName))
                {
                    string[] files = null;
                    try {
                        files = System.IO.Directory.GetFiles(currentTempName, "*.sln");
                        if (files.Length > 0)
                        {
                            // TODO: Currently defaulting to last one, but should ask the user which one to use if there is more than one
                            strSolutionFullFileName = files[files.Length - 1];
                            boolSolutionFileFound   = true;
                            strSolutionName         = strSolutionFullFileName.Substring(strSolutionFullFileName.LastIndexOf("\\") + 1).Replace(".sln", "");
                            myWindowTitles          = myActions.GetWindowTitlesByProcessName("devenv");
                            myWindowTitles.RemoveAll(vsItem => vsItem == "");
                            bool boolVSMatchingSolutionFound = false;
                            foreach (var vsTitle in myWindowTitles)
                            {
                                if (vsTitle.StartsWith(strSolutionName + " - "))
                                {
                                    boolVSMatchingSolutionFound = true;
                                    myActions.ActivateWindowByTitle(vsTitle, 3);
                                    myActions.Sleep(1000);
                                    myActions.TypeText("{ESCAPE}", 500);
                                    myBeginDelim = new List <string>();
                                    myEndDelim   = new List <string>();
                                    myBeginDelim.Add("\"");
                                    myEndDelim.Add("\"");
                                    delimParms = new FindDelimitedTextParms(myBeginDelim, myEndDelim);

                                    myQuote             = "\"";
                                    delimParms.lines[0] = myOrigEditPlusLine;


                                    myActions.FindDelimitedText(delimParms);
                                    intLastSlash = delimParms.strDelimitedTextFound.LastIndexOf('\\');
                                    if (intLastSlash < 1)
                                    {
                                        myActions.MessageBoxShow("Could not find last slash in in EditPlusLine - aborting");
                                        break;
                                    }
                                    strPathOnly     = delimParms.strDelimitedTextFound.SubstringBetweenIndexes(0, intLastSlash);
                                    strFileNameOnly = delimParms.strDelimitedTextFound.Substring(intLastSlash + 1);
                                    myBeginDelim.Clear();
                                    myEndDelim.Clear();
                                    myBeginDelim.Add("(");
                                    myEndDelim.Add(",");
                                    delimParms          = new FindDelimitedTextParms(myBeginDelim, myEndDelim);
                                    delimParms.lines[0] = myOrigEditPlusLine;
                                    myActions.FindDelimitedText(delimParms);
                                    strLineNumber = delimParms.strDelimitedTextFound;
                                    myActions.TypeText("{ESC}", 2000);
                                    myActions.TypeText("%(f)", 1000);
                                    myActions.TypeText("{DOWN}", 1000);
                                    myActions.TypeText("{RIGHT}", 1000);
                                    myActions.TypeText("f", 1000);
                                    // myActions.TypeText("^(o)", 2000);
                                    myActions.TypeText("%(d)", 1500);
                                    myActions.TypeText(strPathOnly, 1500);
                                    myActions.TypeText("{ENTER}", 500);
                                    myActions.TypeText("%(n)", 500);
                                    myActions.TypeText(strFileNameOnly, 1500);
                                    myActions.TypeText("{ENTER}", 1000);
                                    break;
                                }
                            }
                            if (boolVSMatchingSolutionFound == false)
                            {
                                System.Windows.Forms.DialogResult myResult = myActions.MessageBoxShowWithYesNo("I could not find the solution (" + strSolutionName + ") currently running.\n\r\n\r Do you want me to launch it in Visual Studio for you.\n\r\n\rTo go ahead and launch the solution, click yes, otherwise, click no to cancel");
                                if (myResult == System.Windows.Forms.DialogResult.No)
                                {
                                    return;
                                }
                                string strVSPath = myActions.GetValueByKeyGlobal("VS2013Path");
                                // C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
                                if (strVSPath == "")
                                {
                                    List <ControlEntity> myListControlEntity = new List <ControlEntity>();

                                    ControlEntity myControlEntity = new ControlEntity();
                                    myControlEntity.ControlEntitySetDefaults();
                                    myControlEntity.ControlType = ControlType.Heading;
                                    myControlEntity.Text        = "Specify location of Visual Studio";
                                    myListControlEntity.Add(myControlEntity.CreateControlEntity());


                                    myControlEntity.ControlEntitySetDefaults();
                                    myControlEntity.ControlType  = ControlType.Label;
                                    myControlEntity.ID           = "myLabel";
                                    myControlEntity.Text         = "Visual Studio Executable:";
                                    myControlEntity.RowNumber    = 0;
                                    myControlEntity.ColumnNumber = 0;
                                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                                    myControlEntity.ControlEntitySetDefaults();
                                    myControlEntity.ControlType  = ControlType.TextBox;
                                    myControlEntity.ID           = "myAltExecutable";
                                    myControlEntity.Text         = "";
                                    myControlEntity.RowNumber    = 0;
                                    myControlEntity.ColumnNumber = 1;
                                    myListControlEntity.Add(myControlEntity.CreateControlEntity());

                                    myActions.WindowMultipleControls(ref myListControlEntity, 600, 500, 0, 0);
                                    string strAltExecutable = myListControlEntity.Find(x => x.ID == "myAltExecutable").Text;
                                    myActions.SetValueByKeyGlobal("VS2013Path", strAltExecutable);
                                    strVSPath = strAltExecutable;
                                }
                                myActions.Run(strVSPath, "\"" + strSolutionFullFileName + "\"");
                                myActions.Sleep(10000);
                                myActions.MessageBoxShow("When visual studio finishes loading, please click okay to continue");
                                myActions.TypeText("{ESCAPE}", 500);
                                boolSolutionFileFound = true;
                                strSolutionName       = currentTempName.Substring(currentTempName.LastIndexOf("\\") + 1).Replace(".sln", "");
                                myWindowTitles        = myActions.GetWindowTitlesByProcessName("devenv");
                                myWindowTitles.RemoveAll(vsItem => vsItem == "");
                                boolVSMatchingSolutionFound = false;
                                foreach (var vsTitle in myWindowTitles)
                                {
                                    if (vsTitle.StartsWith(strSolutionName + " - "))
                                    {
                                        boolVSMatchingSolutionFound = true;
                                        myActions.ActivateWindowByTitle(vsTitle, 3);
                                        myActions.Sleep(1000);
                                        myActions.TypeText("{ESCAPE}", 500);
                                        myBeginDelim = new List <string>();
                                        myEndDelim   = new List <string>();
                                        myBeginDelim.Add("\"");
                                        myEndDelim.Add("\"");
                                        delimParms = new FindDelimitedTextParms(myBeginDelim, myEndDelim);

                                        myQuote             = "\"";
                                        delimParms.lines[0] = myOrigEditPlusLine;


                                        myActions.FindDelimitedText(delimParms);
                                        intLastSlash = delimParms.strDelimitedTextFound.LastIndexOf('\\');
                                        if (intLastSlash < 1)
                                        {
                                            myActions.MessageBoxShow("Could not find last slash in in EditPlusLine - aborting");
                                            break;
                                        }
                                        strPathOnly     = delimParms.strDelimitedTextFound.SubstringBetweenIndexes(0, intLastSlash);
                                        strFileNameOnly = delimParms.strDelimitedTextFound.Substring(intLastSlash + 1);
                                        myBeginDelim.Clear();
                                        myEndDelim.Clear();
                                        myBeginDelim.Add("(");
                                        myEndDelim.Add(",");
                                        delimParms          = new FindDelimitedTextParms(myBeginDelim, myEndDelim);
                                        delimParms.lines[0] = myOrigEditPlusLine;
                                        myActions.FindDelimitedText(delimParms);
                                        strLineNumber = delimParms.strDelimitedTextFound;
                                        myActions.TypeText("{ESC}", 2000);
                                        myActions.TypeText("%(f)", 1000);
                                        myActions.TypeText("{DOWN}", 1000);
                                        myActions.TypeText("{RIGHT}", 1000);
                                        myActions.TypeText("f", 1000);
                                        // myActions.TypeText("^(o)", 2000);
                                        myActions.TypeText("%(d)", 1500);
                                        myActions.TypeText(strPathOnly, 1500);
                                        myActions.TypeText("{ENTER}", 500);
                                        myActions.TypeText("%(n)", 500);
                                        myActions.TypeText(strFileNameOnly, 1500);
                                        myActions.TypeText("{ENTER}", 1000);
                                        break;
                                    }
                                }
                            }
                            if (boolVSMatchingSolutionFound == false)
                            {
                                myActions.MessageBoxShow("Could not find visual studio for " + strSolutionName);
                            }
                            break;
                        }
                    } catch (UnauthorizedAccessException e) {
                        Console.WriteLine(e.Message);
                        continue;
                    } catch (System.IO.DirectoryNotFoundException e) {
                        Console.WriteLine(e.Message);
                        continue;
                    } catch (System.IO.PathTooLongException e) {
                        Console.WriteLine(e.Message);
                        continue;
                    } catch (Exception e) {
                        Console.WriteLine(e.Message);
                        continue;
                    }
                }
            }

            myActions.TypeText("^(g)", 500);
            myActions.TypeText(strLineNumber, 500);
            myActions.TypeText("{ENTER}", 500);
            goto myExit;


myExit:

            //myActions.MessageBoxShow("Script completed");
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 25
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("FindDelimitedText"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp1      = new List <ComboBoxPair>();
            intRowCtr = 0;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblFindDelimitedText";
            myControlEntity1.Text         = "Find Delimited Text";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblInputs";
            myControlEntity1.Text         = "Inputs:";
            myControlEntity1.ToolTipx     = "";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lbllines";
            myControlEntity1.Text         = "lines";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtlines";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorlines");;
            myControlEntity1.ToolTipx     = "string[]";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblStartingColumn";
            myControlEntity1.Text         = "StartingColumn";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtStartingColumn";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorStartingColumn");;
            myControlEntity1.ToolTipx     = "int";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblListBeginDelim";
            myControlEntity1.Text         = "ListBeginDelim";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtListBeginDelim";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorListBeginDelim");;
            myControlEntity1.ToolTipx     = "List<string>";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblListEndDelim";
            myControlEntity1.Text         = "ListEndDelim";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtListEndDelim";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorListEndDelim");;
            myControlEntity1.ToolTipx     = "List<string>";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblEmptyRow9";
            myControlEntity1.Text         = "";
            myControlEntity1.ToolTipx     = "&&TOOLTIP";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblLineCtrInputandOut";
            myControlEntity1.Text         = "LineCtr Input and Out:";
            myControlEntity1.ToolTipx     = "";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblLineCtr";
            myControlEntity1.Text         = "LineCtr";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtLineCtr";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorLineCtr");;
            myControlEntity1.ToolTipx     = "int";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblEmptyRow12";
            myControlEntity1.Text         = "";
            myControlEntity1.ToolTipx     = "&&TOOLTIP";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblOutputparmsfollow";
            myControlEntity1.Text         = "Output parms follow:";
            myControlEntity1.ToolTipx     = "";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblstrDelimitedTextFound";
            myControlEntity1.Text         = "strDelimitedTextFound";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtstrDelimitedTextFound";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorstrDelimitedTextFound");;
            myControlEntity1.ToolTipx     = "string";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblintDelimFound";
            myControlEntity1.Text         = "intDelimFound";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtintDelimFound";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorintDelimFound");;
            myControlEntity1.ToolTipx     = "int";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblstrResultTypeFound";
            myControlEntity1.Text         = "strResultTypeFound";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtstrResultTypeFound";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorstrResultTypeFound");;
            myControlEntity1.ToolTipx     = "string";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblintEndDelimColPosFound";
            myControlEntity1.Text         = "intEndDelimColPosFound";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtintEndDelimColPosFound";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorintEndDelimColPosFound");;
            myControlEntity1.ToolTipx     = "int";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblExample";
            myControlEntity1.Text         = "Example:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.TextBox;
            myControlEntity1.ID          = "txtExample";
            myControlEntity1.Height      = 250;
            myControlEntity1.Text        = "     // Here is an example of looking for what is between two quotes  \r\n" +
                                           "      // in a single line of text in order to find path and file name \r\n" +
                                           "      List<string> myBeginDelim = new List<string>(); \r\n" +
                                           "      List<string> myEndDelim = new List<string>(); \r\n" +
                                           "      myBeginDelim.Add(\"\\\"\"); \r\n" +
                                           "      myEndDelim.Add(\"\\\"\"); \r\n" +
                                           "      FindDelimitedTextParms delimParms = new FindDelimitedTextParms(myBeginDelim, myEndDelim); \r\n" +
                                           " \r\n" +
                                           "      string myQuote = \"\\\"\"; \r\n" +
                                           "      delimParms.lines[0] = myOrigEditPlusLine; \r\n" +
                                           " \r\n" +
                                           " \r\n" +
                                           "      myActions.FindDelimitedText(delimParms); \r\n" +
                                           "      int intLastSlash = delimParms.strDelimitedTextFound.LastIndexOf('\\\\'); \r\n" +
                                           "      if (intLastSlash < 1) { \r\n" +
                                           "        myActions.MessageBoxShow(\"Could not find last slash in in EditPlusLine - aborting\"); \r\n" +
                                           "        goto myExit;     \r\n" +
                                           "      } \r\n" +
                                           "      string strPathOnly = delimParms.strDelimitedTextFound.SubstringBetweenIndexes(0, intLastSlash); \r\n" +
                                           "      string strFileNameOnly = delimParms.strDelimitedTextFound.Substring(intLastSlash + 1); \r\n" +
                                           "      myBeginDelim.Clear(); \r\n" +
                                           "      myEndDelim.Clear(); \r\n" +
                                           " \r\n" +
                                           "      // in this example, we are trying to find line number that is between open \r\n" +
                                           "      // paren and comma \r\n" +
                                           "      myBeginDelim.Add(\"(\"); \r\n" +
                                           "      myEndDelim.Add(\",\"); \r\n" +
                                           "      delimParms = new FindDelimitedTextParms(myBeginDelim, myEndDelim); \r\n" +
                                           "      delimParms.lines[0] = myOrigEditPlusLine; \r\n" +
                                           "      myActions.FindDelimitedText(delimParms); \r\n" +
                                           "      string strLineNumber = delimParms.strDelimitedTextFound; ";

            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 750, 800, intWindowTop, intWindowLeft);
            string strlines         = myListControlEntity1.Find(x => x.ID == "txtlines").Text;

            myActions.SetValueByKey("ScriptGeneratorlines", strlines);
            string strStartingColumn = myListControlEntity1.Find(x => x.ID == "txtStartingColumn").Text;

            myActions.SetValueByKey("ScriptGeneratorStartingColumn", strStartingColumn);
            string strListBeginDelim = myListControlEntity1.Find(x => x.ID == "txtListBeginDelim").Text;

            myActions.SetValueByKey("ScriptGeneratorListBeginDelim", strListBeginDelim);
            string strListEndDelim = myListControlEntity1.Find(x => x.ID == "txtListEndDelim").Text;

            myActions.SetValueByKey("ScriptGeneratorListEndDelim", strListEndDelim);
            string strLineCtr = myListControlEntity1.Find(x => x.ID == "txtLineCtr").Text;

            myActions.SetValueByKey("ScriptGeneratorLineCtr", strLineCtr);
            string strstrDelimitedTextFound = myListControlEntity1.Find(x => x.ID == "txtstrDelimitedTextFound").Text;

            myActions.SetValueByKey("ScriptGeneratorstrDelimitedTextFound", strstrDelimitedTextFound);
            string strintDelimFound = myListControlEntity1.Find(x => x.ID == "txtintDelimFound").Text;

            myActions.SetValueByKey("ScriptGeneratorintDelimFound", strintDelimFound);
            string strstrResultTypeFound = myListControlEntity1.Find(x => x.ID == "txtstrResultTypeFound").Text;

            myActions.SetValueByKey("ScriptGeneratorstrResultTypeFound", strstrResultTypeFound);
            string strintEndDelimColPosFound = myListControlEntity1.Find(x => x.ID == "txtintEndDelimColPosFound").Text;

            myActions.SetValueByKey("ScriptGeneratorintEndDelimColPosFound", strintEndDelimColPosFound);
            string strInFile = strApplicationPath + "Templates\\TemplateFindDelimitedText.txt";

            // private string strInFile = @"C:\Data\LanguageXMLInput3.txt";

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            List <string> listOfSolvedProblems = new List <string>();
            List <string> listofRecs           = new List <string>();

            string[] lineszz = System.IO.File.ReadAllLines(strInFile);

            sb.Length = 0;

            int intLineCount = lineszz.Count();
            int intCtr       = 0;

            for (int i = 0; i < intLineCount; i++)
            {
                string line = lineszz[i];
                line = line.Replace("&&ListBeginDelim", strListBeginDelim.Trim());
                line = line.Replace("&&ListEndDelim", strListEndDelim.Trim());
                line = line.Replace("&&lines", strlines.Trim());
                if (strStartingColumn != "")
                {
                    line = line.Replace("&&intStartingColumn", strStartingColumn);
                }
                if (strLineCtr != "")
                {
                    line = line.Replace("&&intLineCtr", strLineCtr);
                }
                if (strstrDelimitedTextFound != "")
                {
                    line = line.Replace("&&strDelimitedTextFound", strstrDelimitedTextFound);
                }
                if (strintDelimFound != "")
                {
                    line = line.Replace("&&intDelimTextFound", strintDelimFound);
                }
                if (strstrResultTypeFound != "")
                {
                    line = line.Replace("&&strResultTypeFound", strstrResultTypeFound);
                }
                if (strintEndDelimColPosFound != "")
                {
                    line = line.Replace("&&intEndDelimColPosFound", strintEndDelimColPosFound);
                }


                if (!line.Contains("&&"))
                {
                    sb.AppendLine(line);
                }
            }
            if (strButtonPressed == "btnOkay")
            {
                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                string strOutFile = strApplicationPath + "TemplateCode3GlobalsNew.txt";
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile))
                {
                    file.WriteLine("static List<string> " + strListBeginDelim.Trim() + " = new List<string>();");
                    file.WriteLine("static List<string> " + strListEndDelim.Trim() + " = new List<string>();");

                    file.WriteLine("static FindDelimitedTextParms delimParms;");
                    file.WriteLine("static string[] " + strlines.Trim() + " = new string[5000];");
                    file.WriteLine("static string " + strstrDelimitedTextFound + " = \"\";");
                    file.WriteLine("static int " + strStartingColumn + " = -1;");
                    file.WriteLine("static int " + strintDelimFound + " = -1;");
                    file.WriteLine("static string " + strstrResultTypeFound + " = \"\";");
                    file.WriteLine("static int " + strintEndDelimColPosFound + " = -1;");
                    file.WriteLine("static int " + strLineCtr + " = -1;");
                }

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, sb.ToString());

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============
                myActions.PutEntityInClipboard(sb.ToString());
                myActions.MessageBoxShow(sb.ToString());
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 26
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("PutAllFastByStoppingOnPerfectMatch"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayPutAllFastByStoppingOnPerfectMatch:
            intRowCtr            = 0;
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp = new List <ComboBoxPair>();
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblPutAllFastByStoppingOnPerfectMatch";
            myControlEntity1.Text         = "PutAllFastByStoppingOnPerfectMatch";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.TextBox;
            myControlEntity1.ID          = "txtSyntax2";
            myControlEntity1.Text        = "      myImage = new ImageEntity();\r\n " +
                                           " \r\n " +
                                           "      if (boolRunningFromHome) { \r\n " +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[homeimage]]\");  \r\n " +
                                           "      } else { \r\n " +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[workimage]]\"); \r\n " +
                                           "      } \r\n " +
                                           "      myImage.Sleep = [[Sleep]];  \r\n " +
                                           "      myImage.Attempts = [[Attempts]];  \r\n " +
                                           "      myImage.RelativeX = [[RelativeX]];  \r\n " +
                                           "      myImage.RelativeY = [[RelativeY]]; \r\n " +
                                           " \r\n " +
                                           "      int[,] [[ResultMyArray]] = myActions.PutAllFastByStoppingOnPerfectMatch(myImage); \r\n" +
                                           "      if ([[ResultMyArray]].Length == 0) { \r\n" +
                                           "        myActions.MessageBoxShow(\"I could not find image of SVN Update\"); \r\n" +
                                           "      } \r\n" +
                                           "      // We found output completed and now want to copy the results \r\n" +
                                           "      // to notepad \r\n" +
                                           " \r\n" +
                                           "      // Highlight the output completed line \r\n" +
                                           "      myActions.Sleep(1000); \r\n" +
                                           "      myActions.LeftClick(myArray); ";
            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.Height       = 225;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblHomeImage";
            myControlEntity1.Text         = "HomeImage";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtHomeImage";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorHomeImage");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblWorkImage";
            myControlEntity1.Text         = "WorkImage";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtWorkImage";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorWorkImage");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSleep";
            myControlEntity1.Text         = "Sleep";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSleep";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorSleep");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblAttempts";
            myControlEntity1.Text         = "Attempts";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtAttempts";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorAttempts");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblRelativeX";
            myControlEntity1.Text         = "RelativeX";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtRelativeX";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorRelativeX");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblRelativeY";
            myControlEntity1.Text         = "RelativeY";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtRelativeY";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorRelativeY");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblEmptyRow7";
            myControlEntity1.Text         = "";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblOccurrence";
            myControlEntity1.Text         = "Occurrence";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtOccurrence";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorOccurrence");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblTolerance";
            myControlEntity1.Text         = "Tolerance";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtTolerance";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorTolerance");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblUseGrayScale";
            myControlEntity1.Text         = "UseGrayScale";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("True", "True"));
            cbp.Add(new ComboBoxPair("False", "False"));
            myControlEntity1.ListOfKeyValuePairs = cbp;
            myControlEntity1.SelectedValue       = myActions.GetValueByKey("ScriptGeneratorUseGrayScale");
            myControlEntity1.ID           = "cbxUseGrayScale";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblOutput";
            myControlEntity1.Text         = "Output:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblValue";
            myControlEntity1.Text         = "ResultMyArray:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtResultMyArray";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorPutAllFastByStoppingOnPerfectMatchResultMyArray");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 700, 700, intWindowTop, intWindowLeft);
            string strHomeImage     = myListControlEntity1.Find(x => x.ID == "txtHomeImage").Text;
            string strWorkImage     = myListControlEntity1.Find(x => x.ID == "txtWorkImage").Text;
            string strSleep         = myListControlEntity1.Find(x => x.ID == "txtSleep").Text;
            string strAttempts      = myListControlEntity1.Find(x => x.ID == "txtAttempts").Text;
            string strRelativeX     = myListControlEntity1.Find(x => x.ID == "txtRelativeX").Text;
            string strRelativeY     = myListControlEntity1.Find(x => x.ID == "txtRelativeY").Text;
            string strOccurrence    = myListControlEntity1.Find(x => x.ID == "txtOccurrence").Text;
            string strTolerance     = myListControlEntity1.Find(x => x.ID == "txtTolerance").Text;
            string strUseGrayScale  = myListControlEntity1.Find(x => x.ID == "cbxUseGrayScale").SelectedValue;

            myActions.SetValueByKey("ScriptGeneratorHomeImage", strHomeImage);
            myActions.SetValueByKey("ScriptGeneratorWorkImage", strWorkImage);
            myActions.SetValueByKey("ScriptGeneratorSleep", strSleep);
            myActions.SetValueByKey("ScriptGeneratorAttempts", strAttempts);
            myActions.SetValueByKey("ScriptGeneratorRelativeX", strRelativeX);
            myActions.SetValueByKey("ScriptGeneratorRelativeY", strRelativeY);
            myActions.SetValueByKey("ScriptGeneratorOccurrence", strOccurrence);
            myActions.SetValueByKey("ScriptGeneratorTolerance", strTolerance);
            myActions.SetValueByKey("ScriptGeneratorUseGrayScale", strUseGrayScale);

            string strResultMyArray = myListControlEntity1.Find(x => x.ID == "txtResultMyArray").Text;

            myActions.SetValueByKey("ScriptGeneratorPutAllFastByStoppingOnPerfectMatchResultMyArray", strResultMyArray);
            //   myActions.SetValueByKey("ScriptGeneratorShowOption", strShowOption);

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            string strResultMyArrayToUse = "";

            if (strButtonPressed == "btnOkay")
            {
                strResultMyArrayToUse = strResultMyArray.Trim();
            }
            string strInFile = strApplicationPath + "Templates\\TemplatePutAllFastByStoppingOnPerfectMatch.txt";
            // private string strInFile = @"C:\Data\LanguageXMLInput3.txt";

            List <string> listOfSolvedProblems = new List <string>();
            List <string> listofRecs           = new List <string>();

            string[] lineszz = System.IO.File.ReadAllLines(strInFile);

            sb.Length = 0;

            int intLineCount = lineszz.Count();
            int intCtr       = 0;

            for (int i = 0; i < intLineCount; i++)
            {
                string line = lineszz[i];
                line = line.Replace("&&HomeImage", strHomeImage.Trim());
                line = line.Replace("&&WorkImage", strWorkImage.Trim());
                line = line.Replace("&&ResultMyArray", strResultMyArrayToUse.Trim());
                if (strSleep != "")
                {
                    line = line.Replace("&&Sleep", strSleep);
                }
                if (strAttempts != "")
                {
                    line = line.Replace("&&Attempts", strAttempts);
                }
                if (strRelativeX != "")
                {
                    line = line.Replace("&&RelativeX", strRelativeX);
                }
                if (strRelativeY != "")
                {
                    line = line.Replace("&&RelativeY", strRelativeY);
                }
                if (strOccurrence != "")
                {
                    line = line.Replace("&&Occurrence", strOccurrence);
                }
                if (strTolerance != "")
                {
                    line = line.Replace("&&Tolerance", strTolerance);
                }
                if (strUseGrayScale == "")
                {
                    strUseGrayScale = "false";
                }
                if (strUseGrayScale.ToLower() != "false")
                {
                    line = line.Replace("&&UseGrayScale", strUseGrayScale);
                }

                if (!line.Contains("&&"))
                {
                    sb.AppendLine(line);
                }
            }
            if (strButtonPressed == "btnOkay")
            {
                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                string strOutFile = strApplicationPath + "TemplateCode3GlobalsNew.txt";
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile))
                {
                    file.WriteLine("static int[,] " + strResultMyArrayToUse.Trim() + " = new int[100,100];");
                    file.WriteLine("static ImageEntity myImage = new ImageEntity();");
                    file.WriteLine("static bool boolRunningFromHome = true;");
                }

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, sb.ToString());

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============
                myActions.PutEntityInClipboard(sb.ToString());
                myActions.MessageBoxShow(sb.ToString());
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 27
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("WindowShape"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");

DisplayWindowShape:
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp       = new List <ComboBoxPair>();
            cbp1      = new List <ComboBoxPair>();
            intRowCtr = 0;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblWindowShape";
            myControlEntity1.Text         = "Activate Window By Title";
            myControlEntity1.Width        = 300;
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSyntax2";
            myControlEntity1.Text         = "myActions.WindowShape([[Shape]], [[Orientation]], [[Title]], [[Content]], [[Top]], [[Left]]);";
            myControlEntity1.ColumnSpan   = 5;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblInput";
            myControlEntity1.Text         = "Input:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblShape";
            myControlEntity1.Text         = "Shape:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.ComboBox;
            cbp.Clear();
            cbp.Add(new ComboBoxPair("Box", "Box"));
            cbp.Add(new ComboBoxPair("Arrow", "Arrow"));
            myControlEntity1.ListOfKeyValuePairs = cbp;
            myControlEntity1.SelectedValue       = myControlEntity1.SelectedValue = myActions.GetValueByKey("ScriptGeneratorShape");
            if (myControlEntity1.SelectedValue == null)
            {
                myControlEntity1.SelectedValue = "--Select Item ---";
            }
            myControlEntity1.ID           = "cbxShape";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblOrientation";
            myControlEntity1.Text         = "Orientation:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.ComboBox;
            cbp1.Clear();
            cbp1.Add(new ComboBoxPair("Left", "Left"));
            cbp1.Add(new ComboBoxPair("Right", "Right"));
            cbp1.Add(new ComboBoxPair("Up", "Up"));
            cbp1.Add(new ComboBoxPair("Down", "Down"));

            myControlEntity1.ListOfKeyValuePairs = cbp1;
            myControlEntity1.SelectedValue       = myControlEntity1.SelectedValue = myActions.GetValueByKey("ScriptGeneratorOrientation");
            if (myControlEntity1.SelectedValue == null)
            {
                myControlEntity1.SelectedValue = "--Select Item ---";
            }
            myControlEntity1.ID           = "cbxOrientation";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblTitle";
            myControlEntity1.Text         = "Title:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtTitle";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorTitlex");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myControlEntity1.ColumnSpan   = 5;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblContent";
            myControlEntity1.Text         = "Content:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtContent";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorContentx");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.Height       = 100;
            myControlEntity1.Multiline    = true;
            myControlEntity1.ColumnNumber = 1;
            myControlEntity1.ColumnSpan   = 5;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblTop";
            myControlEntity1.Text         = "Top:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtTop";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorTopx");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblLeft";
            myControlEntity1.Text         = "Left:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtLeft";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorLeftx");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 500, 700, intWindowTop, intWindowLeft);

            string strTitlex      = myListControlEntity1.Find(x => x.ID == "txtTitle").Text;
            string strContentx    = myListControlEntity1.Find(x => x.ID == "txtContent").Text;
            string strTopx        = myListControlEntity1.Find(x => x.ID == "txtTop").Text;
            string strLeftx       = myListControlEntity1.Find(x => x.ID == "txtLeft").Text;
            string strShape       = myListControlEntity1.Find(x => x.ID == "cbxShape").SelectedValue;
            string strOrientation = myListControlEntity1.Find(x => x.ID == "cbxOrientation").SelectedValue;

            myActions.SetValueByKey("ScriptGeneratorTitlex", strTitlex);
            myActions.SetValueByKey("ScriptGeneratorContentx", strContentx);
            myActions.SetValueByKey("ScriptGeneratorTopx", strTopx);
            myActions.SetValueByKey("ScriptGeneratorLeftx", strLeftx);
            myActions.SetValueByKey("ScriptGeneratorShape", strShape);
            myActions.SetValueByKey("ScriptGeneratorOrientation", strOrientation);

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            if (strButtonPressed == "btnOkay")
            {
                string strGeneratedLinex = "";

                strGeneratedLinex = "myActions.WindowShape(\"" + strShape + "\", \"" + strOrientation + "\", \"" + strTitlex + "\", \"" + strContentx + "\"," + strTopx + ", " + strLeftx + ");";

                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, strGeneratedLinex);

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============
                myActions.PutEntityInClipboard(strGeneratedLinex);
                myActions.MessageBoxShow(strGeneratedLinex + Environment.NewLine + Environment.NewLine + "The generated text has been put into your clipboard");
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 28
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("RightClick"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            int                  intWindowTop         = 0;
            int                  intWindowLeft        = 0;
            int                  intRowCtr            = 0;
            ControlEntity        myControlEntity1     = new ControlEntity();
            List <ControlEntity> myListControlEntity1 = new List <ControlEntity>();
            List <ComboBoxPair>  cbp  = new List <ComboBoxPair>();
            List <ComboBoxPair>  cbp1 = new List <ComboBoxPair>();

            string strApplicationPath = System.AppDomain.CurrentDomain.BaseDirectory;

            StringBuilder sb = new StringBuilder(); // this is for creating the controls in the window

            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Script Generator";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());

            // get project folder
            string directory = AppDomain.CurrentDomain.BaseDirectory;

            directory = directory.Replace("\\bin\\Debug\\", "");
            int intLastSlashIndex = directory.LastIndexOf("\\");


DisplayRightClick:
            myControlEntity1     = new ControlEntity();
            myListControlEntity1 = new List <ControlEntity>();
            cbp       = new List <ComboBoxPair>();
            intRowCtr = 0;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Heading;
            myControlEntity1.ID           = "lblRightClick";
            myControlEntity1.Text         = "RightClick";
            myControlEntity1.Width        = 300;
            myControlEntity1.RowNumber    = 0;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblSyntax";
            myControlEntity1.Text         = "Syntax:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtSyntax2";
            myControlEntity1.Text         = "myActions.RightClick([[myArray]]);";
            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblInput";
            myControlEntity1.Text         = "Input:";
            myControlEntity1.FontFamilyx  = new FontFamily("Segoe UI Bold");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblmyArray";
            myControlEntity1.Text         = "myArray:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.TextBox;
            myControlEntity1.ID           = "txtmyArray";
            myControlEntity1.Text         = myActions.GetValueByKey("ScriptGeneratorRightClickmyArray");
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());



            intRowCtr++;
            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType  = ControlType.Label;
            myControlEntity1.ID           = "lblExample";
            myControlEntity1.Text         = "Example:";
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 0;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            myControlEntity1.ControlEntitySetDefaults();
            myControlEntity1.ControlType = ControlType.TextBox;
            myControlEntity1.ID          = "txtExample";
            myControlEntity1.Height      = 250;
            myControlEntity1.Text        = "      ImageEntity myImage = new ImageEntity(); \r\n" +
                                           " \r\n" +
                                           "      if (boolRunningFromHome) { \r\n" +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[homeimage]]\");  \r\n " +
                                           "      } else { \r\n " +
                                           "        myImage.ImageFile = myActions.ConvertWebImageToLocalFile(@\"[[workimage]]\"); \r\n " +
                                           "      } \r\n" +
                                           "      myImage.Sleep = 200; \r\n" +
                                           "      myImage.Attempts = 5; \r\n" +
                                           "      myImage.RelativeX = 10; \r\n" +
                                           "      myImage.RelativeY = 10; \r\n" +
                                           " \r\n" +
                                           "      int[,] myArray = myActions.PutAll(myImage); \r\n" +
                                           "      if (myArray.Length == 0) { \r\n" +
                                           "        myActions.MessageBoxShow(\"I could not find image of SVN Update\"); \r\n" +
                                           "      } \r\n" +
                                           "      // We found output completed and now want to copy the results \r\n" +
                                           "      // to notepad \r\n" +
                                           " \r\n" +
                                           "      // Highlight the output completed line \r\n" +
                                           "      myActions.Sleep(1000); \r\n" +
                                           "      myActions.RightClick(myArray); ";

            myControlEntity1.ColumnSpan   = 4;
            myControlEntity1.RowNumber    = intRowCtr;
            myControlEntity1.ColumnNumber = 1;
            myListControlEntity1.Add(myControlEntity1.CreateControlEntity());

            string strAppendCodeToExistingFile = myActions.CheckboxForAppendCode(intRowCtr, myControlEntity1, myListControlEntity1);

            string strButtonPressed = myActions.WindowMultipleControls(ref myListControlEntity1, 650, 700, intWindowTop, intWindowLeft);

            string strmyArray = myListControlEntity1.Find(x => x.ID == "txtmyArray").Text;

            myActions.SetValueByKey("ScriptGeneratorRightClickmyArray", strmyArray);

            strAppendCodeToExistingFile = myActions.GetAndUpdateValueForCheckBoxAppendCode(myListControlEntity1);

            if (strButtonPressed == "btnDDLRefresh")
            {
                goto DisplayRightClick;
            }

            if (strButtonPressed == "btnOkay")
            {
                string strmyArrayToUse = "";

                strmyArrayToUse = strmyArray.Trim();

                string strGeneratedLinex = "";

                strGeneratedLinex = "myActions.RightClick(" + strmyArrayToUse + ");";
                // ============

                myActions.Write1UsingsTemplateToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write2NameSpaceClassTemplateToExternalFile(strApplicationPath);

                string strOutFile = strApplicationPath + "TemplateCode3GlobalsNew.txt";
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(strOutFile))
                {
                    file.WriteLine("static int[,] " + strmyArrayToUse + " = new int[1,1];");
                }

                myActions.Write3GlobalsToExternalFile(strApplicationPath, strAppendCodeToExistingFile);

                myActions.Write4MainTemplateToExternalFile(strApplicationPath);

                string strOutCodeBodyFile = @"C:\Data\CodeBody.txt";
                WriteCodeBodyToExternalFile(strAppendCodeToExistingFile, strOutCodeBodyFile, strmyArrayToUse);

                myActions.Write5FunctionsTemplateToExternalFile(strApplicationPath);

                myActions.WriteCodeEndToExternalFile();

                string strOutCodeBigFile = myActions.WriteCodeBigExternalFile(strOutCodeBodyFile);

                string strExecutable = @"C:\Windows\system32\notepad.exe";
                string strContent    = strOutCodeBigFile;
                Process.Start(strExecutable, string.Concat("", strContent, ""));

                //============
                myActions.PutEntityInClipboard(strGeneratedLinex);
                myActions.MessageBoxShow(strGeneratedLinex + Environment.NewLine + Environment.NewLine + "The generated text has been put into your clipboard");
            }
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Ejemplo n.º 29
0
        public MainWindow()
        {
            bool boolRunningFromHome = false;
            var  window = new Window() //make sure the window is invisible
            {
                Width         = 0,
                Height        = 0,
                Left          = -2000,
                WindowStyle   = WindowStyle.None,
                ShowInTaskbar = false,
                ShowActivated = false,
            };

            window.Show();
            IdealAutomate.Core.Methods myActions = new Methods();
            myActions.ScriptStartedUpdateStats();

            InitializeComponent();
            this.Hide();

            string strWindowTitle = myActions.PutWindowTitleInEntity();

            if (strWindowTitle.StartsWith("CreateOPFrom3Fields"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
NextOne:
            List <string> myWindowTitles = myActions.GetWindowTitlesByProcessName("chrome");

            myWindowTitles.RemoveAll(item => item == "");
            if (myWindowTitles.Count > 0)
            {
                myActions.ActivateWindowByTitle(myWindowTitles[0], 3);
            }
            List <ControlEntity> myListControlEntity = new List <ControlEntity>();

            ControlEntity myControlEntity = new ControlEntity();

            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType = ControlType.Heading;
            myControlEntity.Text        = "Multiple Controls";
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabelTitle";
            myControlEntity.Text         = "Enter Title";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBoxTitle";
            myControlEntity.Text         = "";
            myControlEntity.RowNumber    = 0;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabelHours";
            myControlEntity.Text         = "Enter Hours";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBoxHours";
            myControlEntity.Text         = "";
            myControlEntity.RowNumber    = 1;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.Label;
            myControlEntity.ID           = "myLabelURL";
            myControlEntity.Text         = "Enter URL";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 0;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());


            myControlEntity.ControlEntitySetDefaults();
            myControlEntity.ControlType  = ControlType.TextBox;
            myControlEntity.ID           = "myTextBoxURL";
            myControlEntity.Text         = "";
            myControlEntity.RowNumber    = 2;
            myControlEntity.ColumnNumber = 1;
            myListControlEntity.Add(myControlEntity.CreateControlEntity());



            myActions.WindowMultipleControls(ref myListControlEntity, 700, 1300, 0, 0);

            string myTitle = myListControlEntity.Find(x => x.ID == "myTextBoxTitle").Text;
            string myHours = myListControlEntity.Find(x => x.ID == "myTextBoxHours").Text;
            string myURL   = myListControlEntity.Find(x => x.ID == "myTextBoxURL").Text;



            string myCode = "<li><a href=\"" + myURL.Trim() + "\" target=\"_blank\">" + myTitle.Trim() + " - " + myHours.Trim() + " hrs</a></li>";

            myActions.PutEntityInClipboard(myCode);
            myWindowTitles = myActions.GetWindowTitlesByProcessName("notepad++");
            myWindowTitles.RemoveAll(item => item == "");
            if (myWindowTitles.Count > 0)
            {
                myActions.ActivateWindowByTitle(myWindowTitles[0], 3);
            }
            myActions.MessageBoxShow("Paste");
            goto NextOne;
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }