public override void RunCommand(object sender)
        {
            var      engine     = (IAutomationEngineInstance)sender;
            string   windowName = v_WindowName.ConvertUserVariableToString(engine);
            int      timeout    = Int32.Parse(v_Timeout);
            DateTime timeToEnd  = DateTime.Now.AddSeconds(timeout);

            while (timeToEnd >= DateTime.Now)
            {
                try
                {
                    if (engine.IsCancellationPending)
                    {
                        break;
                    }
                    List <IntPtr> targetWindows = User32Functions.FindTargetWindows(windowName);
                    if (targetWindows.Count == 0)
                    {
                        throw new Exception($"Window '{windowName}' Not Yet Found... ");
                    }
                    break;
                }
                catch (Exception)
                {
                    engine.ReportProgress($"Window '{windowName}' Not Yet Found... " + (timeToEnd - DateTime.Now).Minutes + "m, " + (timeToEnd - DateTime.Now).Seconds + "s remain");
                    Thread.Sleep(500);
                }
            }

            var variableXPosition = v_XMousePosition.ConvertUserVariableToString(engine);
            var variableYPosition = v_YMousePosition.ConvertUserVariableToString(engine);

            User32Functions.MoveWindow(windowName, variableXPosition, variableYPosition);
        }
예제 #2
0
        public override void RunCommand(object sender)
        {
            var    engine            = (AutomationEngineInstance)sender;
            string windowName        = v_WindowName.ConvertUserVariableToString(engine);
            var    variableXPosition = v_XMousePosition.ConvertUserVariableToString(engine);
            var    variableYPosition = v_YMousePosition.ConvertUserVariableToString(engine);

            User32Functions.MoveWindow(windowName, variableXPosition, variableYPosition);
        }
예제 #3
0
        public async override Task RunCommand(object sender)
        {
            var    engine     = (IAutomationEngineInstance)sender;
            string windowName = (string)await v_WindowName.EvaluateCode(engine);

            var variableXPosition = (int)await v_XMousePosition.EvaluateCode(engine);

            var variableYPosition = (int)await v_YMousePosition.EvaluateCode(engine);

            int timeout = (int)await v_Timeout.EvaluateCode(engine);

            DateTime timeToEnd = DateTime.Now.AddSeconds(timeout);

            while (timeToEnd >= DateTime.Now)
            {
                try
                {
                    if (engine.IsCancellationPending)
                    {
                        break;
                    }
                    List <IntPtr> targetWindows = User32Functions.FindTargetWindows(windowName);
                    if (targetWindows.Count == 0)
                    {
                        throw new Exception($"Window '{windowName}' Not Yet Found... ");
                    }
                    break;
                }
                catch (Exception)
                {
                    engine.ReportProgress($"Window '{windowName}' Not Yet Found... {(timeToEnd - DateTime.Now).Minutes}m, {(timeToEnd - DateTime.Now).Seconds}s remain");
                    Thread.Sleep(500);
                }
            }



            User32Functions.MoveWindow(windowName, variableXPosition.ToString(), variableYPosition.ToString());
        }
        //combobox events for form items

        #region ComboBox Events

        private void cboIEWindow_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var shellWindows = new ShellWindows();

            foreach (IWebBrowser2 shellWindow in shellWindows)
            {
                if (shellWindow.Document is HTMLDocument)
                {
                    if (shellWindow.Document.Title == cboIEWindow.Text)
                    {
                        _ie = shellWindow.Application;
                        var events = (HTMLDocumentEvents2_Event)_ie.Document;

                        events.onclick += (evt) =>
                        {
                            _searchParameters = new DataTable();
                            _searchParameters.Columns.Add("Enabled");
                            _searchParameters.Columns.Add("Property Name");
                            _searchParameters.Columns.Add("Property Value");

                            if (evt.srcElement is IHTMLElement)
                            {
                                IHTMLElement srcInfo           = evt.srcElement;
                                var          elementProperties = srcInfo.GetType().GetProperties();

                                foreach (PropertyInfo prp in elementProperties)
                                {
                                    var propIsString = prp.PropertyType == typeof(string);
                                    var propIsInt    = prp.PropertyType == typeof(int);

                                    if ((propIsString || propIsInt) && !prp.Name.Contains("IHTML"))
                                    {
                                        string propName  = prp.Name;
                                        string propValue = Convert.ToString(prp.GetValue(srcInfo));
                                        _searchParameters.Rows.Add(false, propName, propValue);
                                    }
                                }

                                dgvSearchParameters.Invoke(new MethodInvoker(() =>
                                {
                                    dgvSearchParameters.DataSource = _searchParameters;
                                })
                                                           );
                            }

                            return(false);
                        };

                        var windowName = cboIEWindow.Text + " - Internet Explorer";
                        User32Functions.ActivateWindow(windowName);
                        User32Functions.MoveWindow(windowName, "0", "0");

                        MoveFormToBottomRight(this);
                        TopMost = true;

                        foreach (Form frm in Application.OpenForms)
                        {
                            if (frm.Name != Name)
                            {
                                frm.WindowState = FormWindowState.Minimized;
                            }
                        }
                    }
                }
            }
        }