public static void RefreshPrintTab(IntPtr hwnd) { System.Threading.Tasks.Task.Run(() => { var item = BackStageItem.GetBackStageItem(hwnd); if (item.Columns.Count <= 0) { return; } var con = new System.Windows.Automation.PropertyCondition(System.Windows.Automation.AutomationElement.AccessKeyProperty, "Alt, F, P, R"); var btn = item.BackStage.FindFirst(System.Windows.Automation.TreeScope.Subtree, con); if (btn == null) { return; } var ip = btn.GetCurrentPattern(System.Windows.Automation.InvokePattern.Pattern) as System.Windows.Automation.InvokePattern; if (ip == null) { return; } ip.Invoke(); con = new System.Windows.Automation.PropertyCondition(System.Windows.Automation.AutomationElement.ClassNameProperty, "#32770"); System.Windows.Automation.AutomationElement dlg; IntPtr hwndDlg = IntPtr.Zero; do { dlg = item.wnd.FindFirst(System.Windows.Automation.TreeScope.Subtree, con); } while (dlg == null || dlg.Current.NativeWindowHandle == 0); con = new System.Windows.Automation.PropertyCondition(System.Windows.Automation.AutomationElement.ControlTypeProperty, System.Windows.Automation.ControlType.Button); var buttons = dlg.FindAll(System.Windows.Automation.TreeScope.Subtree, con); foreach (System.Windows.Automation.AutomationElement b in buttons) { System.Diagnostics.Debug.WriteLine(b.Current.Name + "\t" + b.Current.AccessKey); } con = new System.Windows.Automation.PropertyCondition(System.Windows.Automation.AutomationElement.AccessKeyProperty, "Alt+V"); var con2 = new System.Windows.Automation.PropertyCondition(System.Windows.Automation.AutomationElement.AccessKeyProperty, "Alt+v"); var orcon = new System.Windows.Automation.OrCondition(new System.Windows.Automation.Condition[] { con, con2 }); var prev = dlg.FindFirst(System.Windows.Automation.TreeScope.Subtree, orcon); if (prev == null) { return; } var ip2 = prev.GetCurrentPattern(System.Windows.Automation.InvokePattern.Pattern) as System.Windows.Automation.InvokePattern; if (ip2 == null) { return; } dlg.SetFocus(); do { ip2.Invoke(); } while (Win32.IsWindowVisible(hwndDlg)); }); }
public static BackStageRect GetBackStageRect(IntPtr hwnd) { return(BackStageItem.GetBackStageItem(hwnd).ToBackStageRect()); }