Invoke to SendMessage

本文关键字:SendMessage to Invoke | 更新日期: 2023-09-27 18:10:21

我使用WatIn和I保存文件与savea对话框,但是当我锁定windows/pc这个进程停止时,我需要将Invoke转换为SendMessage,当我的pc被锁定时,这个进程仍然会运行。

有办法做到这一点吗?

调用 的一段代码
  private static void ClickSaveAs(AutomationElement mainWindow, AutomationElementCollection dialogElements, string filename)
        {

            foreach (AutomationElement element in dialogElements)
            {
                if (element.Current.Name.Equals("Save"))
                {
                    AutomationElementCollection dialogSubElements = element.FindAll(TreeScope.Children, Automation.ContentViewCondition);
                    InvokePattern clickPatternForSaveDropdown = (InvokePattern)dialogSubElements[0].GetCurrentPattern(AutomationPattern.LookupById(10000));
                //I need to change this to..
                   clickPatternForSaveDropdown.Invoke();
//This
                    //start
                    int intWhdr = FindWindow("IEFrame", "");
                    int currChild = FindWindowEx(intWhdr, 0, "", "Frame Notification Bar");
                    currChild = 104755016;
                    int intRes1 = SendMessage(currChild, WM_LBUTTONDOWN, 0, 0);
                    System.Threading.Thread.Sleep(100);
                    intRes1 = SendMessage(currChild, WM_LBUTTONUP, 0, 1);
                    System.Threading.Thread.Sleep(200);
                    //end
                    Thread.Sleep(1500);
                    AutomationElementCollection dialogElementsInMainWindow = mainWindow.FindAll(TreeScope.Children, Condition.TrueCondition);
                    foreach (AutomationElement currentMainWindowDialogElement in dialogElementsInMainWindow)
                    {
                        if (currentMainWindowDialogElement.Current.LocalizedControlType == "menu")
                        {
                            // first array element 'Save', second array element 'Save as', third second array element    'Save and open'
                            InvokePattern clickMenu = (InvokePattern)currentMainWindowDialogElement.FindAll(TreeScope.Children, Condition.TrueCondition)[1].GetCurrentPattern(AutomationPattern.LookupById(10000));
                            clickMenu.Invoke();
                            Thread.Sleep(1);
                            ControlSaveDialog(mainWindow, filename);
                            break;
                            //strt

                            //end
                        }
                    }
                }
            }
        }

Invoke to SendMessage

机器被锁定时,等待将不工作。因为它使用微软。mshtml和Interop。SHDocVw二进制引用。这些二进制文件是COM组件,需要一个交互式UI。例如,您可以尝试登录本身而不是下载。启动测试,锁定机器,然后解锁。观察结果,它将失败抛出一个错误,如COM异常....尝试使用Reg keys update来永久解锁机器…