【发布时间】:2014-06-25 05:42:25
【问题描述】:
我使用 WatIn 并使用 saveAs 对话框保存文件,但是当我锁定 windows/pc 时,此过程停止,我需要将 Invoke 强制转换为 SendMessage,当我的 pc 锁定时此过程仍将运行。
有没有办法做到这一点?
Invoke 代码片段
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
}
}
}
}
}
【问题讨论】:
标签: c# watin sendmessage postmessage