Exemplo 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("OpenCurrentPageInVS"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            myActions.TypeText("%(d)", 500);
            myActions.TypeText("^(c)", 500);
            List <string> 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;
                }
            }
            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;
            delimParms.strDelimitedTextFound = 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;


            myWindowTitles.RemoveAll(item => item == "");
            if (myWindowTitles.Count > 0)
            {
                if (strFileNameOnly.ToLower().EndsWith("aspx"))
                {
                    myWebSite        = myWindowTitles.Find(x => x.StartsWith("WEB Source"));
                    strFileNameOnly += ".cs";
                }

                if (strFileNameOnly.ToLower().EndsWith("asp"))
                {
                    myWebSite = myWindowTitles.Find(x => x.StartsWith("WebApp"));
                }



                if (myWebSite == "" || myWebSite == null)
                {
                    myActions.MessageBoxShow("Could not find an open visual studio for this type of file");
                }
                else
                {
                    myActions.ActivateWindowByTitle(myWebSite, 3);

                    // myActions.MessageBoxShow("just activated vs");
                    myActions.TypeText("{ESC}", 2000);
                    myActions.TypeText("^(;)", 1000);
                    myActions.TypeText(strFileNameOnly, 1500);
                    myActions.TypeText("{ENTER}", 1500);
                    //myActions.TypeText("^(g)", 1000);
                    //myActions.TypeText(strLineNumber, 500);
                    //myActions.TypeText("{ENTER}", 500);
                }
            }
            else
            {
                myActions.MessageBoxShow("Could not find an open visual studio for this type of file");
            }
            goto myExit;


myExit:

            //myActions.MessageBoxShow("Script completed");
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
Exemplo 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("WindowsExplorerGetFileNameOnly") || strWindowTitle.StartsWith("Ideal Automate"))
            {
                myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio
            }
            myActions.Sleep(1000);
            string strActiveTitle = myActions.GetActiveWindowTitle();

            //  myActions.MessageBoxShow(strActiveTitle);
            myActions.ActivateWindowByTitle("WindowMultipleControls", 2);
            myActions.ActivateWindowByTitle(strActiveTitle, 3);

            myActions.TypeText("+({F10})", 500);   // right-click filename in windows explorer
            myActions.TypeText("{UP}", 500);       // highlight properties
            myActions.TypeText("+({ENTER})", 500); // select properties
            myActions.TypeText("+({TAB 2})", 500); // focus filename
            myActions.SelectAllCopy(500);          // Copy filename
            myActions.TypeText("+({TAB 2})", 500); // focus cancel button
            myActions.TypeText("{ENTER}", 500);    // close properties window
            ImageEntity myImage = new ImageEntity();

            myImage.ImageFile = "Images\\imgName.PNG";
            myImage.Sleep     = 1700;
            myImage.Attempts  = 2;
            myImage.RelativeX = 300;
            myImage.RelativeY = -25;
            int[,] myArray    = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                myActions.MessageBoxShow("Could not find imgName - click here to continue");
            }
            else
            {
                myActions.LeftClick(myArray);
            }
            myActions.TypeText("%(d)", 500);  // highlight windows explorer address bar
            myActions.TypeText("{END}", 500); // close properties window
            myActions.TypeText("\\", 500);    // type slash
            string strFileNameOnly = myActions.PutClipboardInEntity();

            myActions.TypeText("^(v)", 500); // paste filename
            myActions.SelectAllCopy(500);    // Copy full filename
            string strFullFileName = myActions.PutClipboardInEntity();
            Bitmap img             = new Bitmap(strFullFileName);

            var imageHeight = img.Height;
            var imageWidth  = img.Width;

            // System.Drawing.Image img = System.Drawing.Image.FromFile(strFullFileName);
            // MessageBox.Show("Width: " + img.Width + ", Height: " + img.Height);
            myActions.ActivateWindowByTitle("WindowMultipleControls", 3);
            myActions.TypeText("{TAB 3}", 1500);
            myActions.TypeText(strFileNameOnly, 500);
            myActions.TypeText("{TAB 2}", 500);
            myActions.TypeText(img.Height.ToString(), 500);
            myActions.TypeText("{TAB}", 500);
            myActions.TypeText(img.Width.ToString(), 500);
            string strFromPath     = @"C:\Users\Rebecca\Downloads\";
            string strToPath       = @"C:\Users\Rebecca\Documents\IdealProgrammerAptHost\public_html\wp-photos\";
            string strFromFullFile = strFromPath + strFileNameOnly;
            string strToFullFile   = strToPath + strFileNameOnly;

            File.Copy(strFromFullFile, strToFullFile, true);
myExit:
            myActions.ScriptEndedSuccessfullyUpdateStats();
            Application.Current.Shutdown();
        }
        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();
        }
Exemplo 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();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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();
        }
Exemplo 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();
            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();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Writes jobs found to database jobapplications
        /// </summary>
        /// <param name="con"></param>
        /// <param name="cmd"></param>
        /// <param name="jobBoard"></param>
        /// <param name="myActions"></param>
        /// <param name="keyword"></param>
        /// <param name="location"></param>
        /// <param name="developermode">the first pass switch</param>
        /// <param name="processNextPage"></param>
        /// <param name="start"></param>
        void PerformSearch(SqlConnection con,
                           SqlCommand cmd,
                           _JobBoardName jobBoard,
                           Methods myActions,
                           string keyword,
                           string location,
                           ref bool developermode,
                           ref bool processNextPage,
                           ref int start)
        {
            //
            // S T A R T   N E W   P R O C E S S:  chrome
            //
            List <string> myWindowTitles4 = myActions.GetWindowTitlesByProcessName("chrome");

            myWindowTitles4.RemoveAll(item => item == "");
            string[] locgeo      = location.Split('|');
            string   myUrlTarget = "";

            switch (jobBoard)
            {
            case _JobBoardName.LinkedIn:
                myUrlTarget = "https://www.linkedin.com/jobs/search/?distance=1&geoId=" + locgeo[1] + "&keywords=" + keyword + "&location=" + locgeo[0] + "%2C%20Illinois%2C%20United%20States&msgConversationId=6647936427130699776&msgOverlay=true&start=" + start;
                break;

            case _JobBoardName.Indeed:
                myUrlTarget = "https://www.indeed.com/jobs?q=" + keyword + "&l=" + locgeo[0] + "%2C+IL&radius=0";
                if (myUrlTarget.Contains("Remote"))
                {
                    myUrlTarget = myUrlTarget.Replace("Remote%2C+IL", "Remote");
                }
                break;

            case _JobBoardName.Glassdoor:
                if (keyword == "c%23")
                {
                    myUrlTarget = "https://www.glassdoor.com/Job/" + locgeo[0] + "-" + "c" + "-" + locgeo[2] + ".htm?radius=0";
                }
                else
                {
                    myUrlTarget = "https://www.glassdoor.com/Job/" + locgeo[0] + "-" + keyword + "-" + locgeo[2] + ".htm?radius=0";
                }
                break;

            case _JobBoardName.Dice:
                myUrlTarget = "https://www.dice.com/jobs?q=" + keyword + "&location=" + locgeo[0] + ",%20IL,%20USA&latitude=" + locgeo[3] + "&longitude=" + locgeo[4] + "&countryCode=US&locationPrecision=City&radius=1&radiusUnit=mi&page=1&pageSize=100&language=en&includeRemote=false";
                if (myUrlTarget.Contains("Remote%2C+IL"))
                {
                    myUrlTarget = myUrlTarget.Replace("Remote%2C+IL", "Remote").Replace("includeRemote=false", "includeRemote=true");
                }
                break;

            //case _JobBoardName.Monster:
            //    break;
            default:
                break;
            }

            if (!myWindowTitles4[0].Contains(jobBoard.ToString()))
            {
                // You may need to manually add content parameter as second parameter for run???
                myActions.Run(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", myUrlTarget);
                myActions.Sleep(1000);
            }
            if (myWindowTitles4.Count > 0)
            {
                myActions.ActivateWindowByTitle(myWindowTitles4[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED);
            }
            if (start > 0)
            {
                myActions.Sleep(2000);
            }

            myActions.TypeText("%(d)", 1500); // select address bar
            myActions.TypeText("^(a)", 1500);
            myActions.TypeText("^(c)", 1500);

            string myUrl = myActions.PutClipboardInEntity();

            if (myUrl != myUrlTarget && jobBoard != _JobBoardName.Glassdoor)
            {
                myActions.SelectAllPasteFromEntity(myUrlTarget, 500);
                myActions.TypeText("{ENTER}", 500);
                //  Console.WriteLine("Enter pressed");
            }
            int         count   = 0;
            ImageEntity myImage = new ImageEntity();

            if (jobBoard != _JobBoardName.Glassdoor)
            {
                // wait for location in title except for dice because dice does not display location in title
                if (jobBoard != _JobBoardName.Dice)
                {
                    while (!myWindowTitles4[0].Contains(locgeo[0]) && count < 10)
                    {
                        myActions.Sleep(1000);
                        myWindowTitles4 = myActions.GetWindowTitlesByProcessName("chrome");
                        myWindowTitles4.RemoveAll(item => item == "");
                        count++;
                    }
                    if (count == 10)
                    {
                        //  Console.WriteLine(string.Format("could not find {0} in title", locgeo[0]));
                    }
                }
checkLoaded:
                myImage = new ImageEntity();
                switch (jobBoard)
                {
                case _JobBoardName.LinkedIn:
                    myImage.ImageFile = "Images\\Jobs.PNG";
                    break;

                case _JobBoardName.Indeed:
                    myImage.ImageFile = "Images\\IndeedLoaded.PNG";
                    break;

                case _JobBoardName.Glassdoor:
                    myImage.ImageFile = "Images\\GlassDoorLoaded.PNG";
                    break;

                case _JobBoardName.Dice:
                    myImage.ImageFile = "Images\\DiceLoaded.PNG";
                    myImage.Tolerance = 99;
                    break;

                //case _JobBoardName.Monster:
                //    break;
                default:
                    break;
                }



                myImage.Sleep     = 2000;
                myImage.Attempts  = 20;
                myImage.RelativeX = 10;
                myImage.RelativeY = 10;



                int[,] myArray2 = myActions.PutAll(myImage);
                if (myArray2.Length == 0)
                {
                    Console.WriteLine("page not loaded");
                    goto checkLoaded;
                }
            }

            myImage           = new ImageEntity();
            myImage.Sleep     = 500;
            myImage.Attempts  = 20;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myImage.Tolerance = 97;

            switch (jobBoard)
            {
            case _JobBoardName.LinkedIn:

                break;

            case _JobBoardName.Indeed:

                break;

            case _JobBoardName.Glassdoor:
                myImage.RelativeX = -100;
                myImage.RelativeY = 20;
                myImage.ImageFile = "Images\\Search.PNG";
                myActions.ClickImageIfExists(myImage);
                myActions.TypeText("^(a)", 500);
                myActions.TypeText(locgeo[0] + ", IL", 500);
                myActions.TypeText("+({TAB})", 500);
                myActions.TypeText("+({TAB})", 500);
                myActions.TypeText("^(a)", 500);
                myActions.TypeText(keyword.Replace("c%23", "c#"), 500);
                myImage.ImageFile = "Images\\Search.PNG";
                myImage.RelativeX = 10;
                myImage.RelativeY = 10;
                myActions.ClickImageIfExists(myImage);
                myActions.Sleep(2000);
                myImage.Tolerance = 99;
                myImage.ImageFile = "Images\\ExactLocation.PNG";
                myActions.ClickImageIfExists(myImage);
                myImage.ImageFile = "Images\\ExactLocationChecked.PNG";
                myActions.ClickImageIfExists(myImage);
                myActions.Sleep(5000);

                break;

            case _JobBoardName.Dice:
                break;

            //case _JobBoardName.Monster:
            //    break;
            default:
                break;
            }



            myImage = new ImageEntity();

            myImage.Sleep     = 200;
            myImage.Attempts  = 1;
            myImage.RelativeX = 10;
            myImage.RelativeY = 10;
            myImage.Tolerance = 99;
            switch (jobBoard)
            {
            case _JobBoardName.LinkedIn:
                myImage.ImageFile = "Images\\NoMatchingJobsLinkedIn.PNG";
                break;

            case _JobBoardName.Indeed:
                myImage.ImageFile = "Images\\NoJobsFoundWithinIndeed.PNG";
                break;

            case _JobBoardName.Glassdoor:
                myImage.ImageFile = "Images\\NoJobsGlassDoor.PNG";
                break;

            case _JobBoardName.Dice:
                myImage.ImageFile = "Images\\NoJobsDice.PNG";

                break;

            //case _JobBoardName.Monster:
            //    break;
            default:
                break;
            }



            int[,] myArray = myActions.PutAll(myImage);
            if (myArray.Length == 0)
            {
                // linkedin steps
                // use ctrl-shift-j to open console
                // ctrl-[ to go to elements
                // ctrl-c
                // read each line looking for href="/jobs/view
                // when line contains href="/jobs/view, need to find closing double quote and add the
                //  text found to url list
                // begin-delim = href="/jobs/view
                // end-delim = double quote

                // first time do ctrl-shift j only once; other times, do it twice to reset everything
                myImage = new ImageEntity();

                myImage.Sleep     = 200;
                myImage.Attempts  = 1;
                myImage.RelativeX = 10;
                myImage.RelativeY = 10;
                myImage.Tolerance = 99;
                myImage.ImageFile = "Images\\DevToolsModeOn.PNG";



                int[,] myArray2 = myActions.PutAll(myImage);
                if (myArray2.Length != 0)
                {
                    // linkedin steps
                    myActions.TypeText("^+(j)", 3500);
                }
                myActions.TypeText("^+(j)", 3500);
                myImage = new ImageEntity();



                myImage.ImageFile = "Images\\DevToolsElements.PNG";



                myImage.Sleep     = 500;
                myImage.Attempts  = 5;
                myImage.RelativeX = 10;
                myImage.RelativeY = 10;
                myImage.Tolerance = 99;



                myArray = myActions.PutAll(myImage);
                if (myArray.Length == 0)
                {
                    Console.WriteLine("could not find elements tab in developer tools");
                }
                myActions.TypeText("^([)", 3500);
                developermode = true;


                myActions.Sleep(2000);
                string myPage            = myActions.SelectAllCopyIntoEntity(2500);
                int    indexOfPagination = myPage.IndexOf("pagination");
                if (indexOfPagination == -1 || jobBoard == _JobBoardName.Indeed || jobBoard == _JobBoardName.Dice)
                {
                    processNextPage = false;
                }
                switch (jobBoard)
                {
                case _JobBoardName.LinkedIn:
                    myPage = FindJobsUpdateDB_LinkedIn(con, cmd, myActions, keyword, locgeo, myPage);

                    break;

                case _JobBoardName.Indeed:
                    myPage = FindJobsUpdateDB_Indeed(con, cmd, myActions, keyword, locgeo, myPage);

                    break;

                case _JobBoardName.Glassdoor:
                    myPage = FindJobsUpdateDB_Glassdoor(con, cmd, myActions, keyword, locgeo, myPage);
                    break;

                case _JobBoardName.Dice:
                    myPage = FindJobsUpdateDB_Dice(con, cmd, myActions, keyword, locgeo, myPage);
                    break;

                //case _JobBoardName.Monster:
                //    break;
                default:
                    break;
                }

                // Console.WriteLine("Jobs found");
            }
            else
            {
                processNextPage = false;
                return;
            }
        }
Exemplo n.º 9
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();
        }
Exemplo 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("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();
        }
Exemplo 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();

            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();
        }
Exemplo 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();
            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();
        }
Exemplo 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("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();
        }