Exemplo n.º 1
0
        public void Execute(Arguments arguments)
        {
            var wrapper = MsCrmManager.CurrentCRM;

            if (wrapper == null)
            {
                throw new ApplicationException("Could not activate Dynamics CRM instance. It has to be attached first.");
            }
            IntPtr iHandle = wrapper.Ie.NativeBrowser.hWnd;

            Scripter.Log.Log(AbstractLogger.Level.Info, "Window '" + wrapper.Title + "' has been found");
            Scripter.LastWindow = (iHandle);
            RobotWin32.BringWindowToFront(iHandle);
            if (arguments.Style.Value.ToLower() == "maximize")
            {
                RobotWin32.ShowWindow(iHandle, RobotWin32.ShowWindowEnum.Maximize);
            }
            else if (arguments.Style.Value.ToLower() == "minimize")
            {
                RobotWin32.ShowWindow(iHandle, RobotWin32.ShowWindowEnum.Minimize);
            }
            else if (arguments.Style.Value.ToLower() == "normal")
            {
                RobotWin32.ShowWindow(iHandle, RobotWin32.ShowWindowEnum.Restore);
            }
        }
Exemplo n.º 2
0
 private void highlightToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (controlsTree.SelectedNode != null)
         {
             if (controlsTree.SelectedNode.Tag is UIElement uiElement)
             {
                 var element = UIElement.FromWPath(uiElement.ToWPath());
                 if (element != null)
                 {
                     var window = GetTopLevelWindow(uiElement.AutomationElement);
                     if (window != null)
                     {
                         var iHandle = window.FrameworkAutomationElement.NativeWindowHandle;
                         if (iHandle != IntPtr.Zero)
                         {
                             RobotWin32.BringWindowToFront(iHandle);
                             var rect = element.GetRectangle();
                             if (rect != null)
                             {
                                 InitializeRectangleForm(rect);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         RobotMessageBox.Show(ex.Message, "Error");
     }
 }
Exemplo n.º 3
0
        public void Execute(Arguments arguments)
        {
            var control = AccessManager.CurrentAccess.GetControlByPath(arguments.Path.Value);

            var handle = (IntPtr)control.GetFormHwnd();

            RobotWin32.BringWindowToFront(handle);
            RobotWin32.ShowWindow(handle, RobotWin32.ShowWindowEnum.Maximize);
            control.SetFocus();
        }
Exemplo n.º 4
0
        private void ActivateBrowserWindow(MsCrmWrapper wrapper)
        {
            if (wrapper == null)
            {
                throw new ApplicationException("Could not activate Dynamics CRM instance. It has to be attached first.");
            }
            IntPtr iHandle = wrapper.Ie.NativeBrowser.hWnd;

            Scripter.Log.Log(AbstractLogger.Level.Info, "Window '" + wrapper.Title + "' has been found");
            Scripter.LastWindow = (iHandle);
            RobotWin32.BringWindowToFront(iHandle);
        }
        internal void OpenAccessObject(AccessObjectModel report)
        {
            try
            {
                var app  = GetCurrentApplication();
                var name = report.FullName ?? report.Name;

                switch (report.Type)
                {
                case MSAccess.AcObjectType.acReport:
                    app.DoCmd.OpenReport(name);
                    break;

                case MSAccess.AcObjectType.acTable:
                    app.DoCmd.OpenTable(name, MSAccess.AcView.acViewNormal, MSAccess.AcOpenDataMode.acReadOnly);
                    break;

                case MSAccess.AcObjectType.acServerView:
                    app.DoCmd.OpenView(name, MSAccess.AcView.acViewNormal, MSAccess.AcOpenDataMode.acReadOnly);
                    break;

                case MSAccess.AcObjectType.acStoredProcedure:
                    app.DoCmd.OpenStoredProcedure(name, MSAccess.AcView.acViewNormal, MSAccess.AcOpenDataMode.acReadOnly);
                    break;

                case MSAccess.AcObjectType.acQuery:
                    app.DoCmd.OpenQuery(name, MSAccess.AcView.acViewNormal, MSAccess.AcOpenDataMode.acReadOnly);
                    break;

                case MSAccess.AcObjectType.acFunction:
                    app.DoCmd.OpenFunction(name, MSAccess.AcView.acViewNormal, MSAccess.AcOpenDataMode.acReadOnly);
                    break;

                case MSAccess.AcObjectType.acDiagram:
                    app.DoCmd.OpenDiagram(name);
                    break;

                case MSAccess.AcObjectType.acMacro:
                    app.DoCmd.RunMacro(name, 1, true);
                    break;

                default:
                    throw new NotImplementedException($"Opener for {report.TypeName} not implemented.");
                }

                RobotWin32.BringWindowToFront((IntPtr)app.hWndAccessApp());
            }
            catch (Exception ex)
            {
                RobotMessageBox.Show(ex.Message);
            }
        }
        private void OpenForm(AccessObjectModel formToLoad, bool openInDesigner, MSAccess.Application application)
        {
            try
            {
                var formName = formToLoad.FullName ?? formToLoad.Name;
                application.DoCmd.OpenForm(
                    formName,
                    openInDesigner ? MSAccess.AcFormView.acDesign : MSAccess.AcFormView.acNormal
                    );

                var form = application.Forms[formName];
                form.SetFocus();
                RobotWin32.BringWindowToFront((IntPtr)form.Hwnd);
            }
            catch (Exception ex)
            {
                RobotMessageBox.Show(ex.Message);
            }
        }