/// <summary> /// 专票红冲改动 /// </summary> static void zhuanpiaohongchong() { //对专票备注进行赋值--貌似不能修改--需要确认 var pageName = "开具增值税专用发票"; var bar = WinApi.FindWindow(null, pageName); var list = WinApi.EnumChilWindowsIntptr(bar); List <IntPtr> list2 = new List <IntPtr>(); for (var i = 2; i < list.Count; i++) { list2 = WinApi.FindChildBar((IntPtr)list[i]); if (list2?.Count >= 22) { break; } } var temp = list2.Select(i => (int)i).ToList(); WinApi.SendMessage(list2[6], 0x0C, IntPtr.Zero, "备注信息"); var list3 = WinApi.FindChildBar(list2[19]); var list4 = WinApi.FindChildBar(list2[21]); foreach (IntPtr t in list3) { //银行名称账号 WinApi.SendMessage(t, 12, IntPtr.Zero, $"银行账号9898989"); } foreach (IntPtr t in list4) { //购方地址,电话 var addressTel = $"购方地 址电话"; WinApi.SendMessage(t, 12, IntPtr.Zero, addressTel); } }
/// <summary> /// 点击自动导入按钮--采用UI自动化方案--使用UI方案查找句柄--精确方法可以使用 /// </summary> static void UIZiDongHua() { Thread.Sleep(2000); var bar = WinApi.FindWindow(null, "开具增值税专用发票"); var list = WinApi.EnumChilWindowsIntptr(bar); var childBar = list[list.Count - 1]; var parentAutomation = AutomationElement.FromHandle(childBar); var listAutomation = parentAutomation. FindAll(TreeScope.Children, Condition.TrueCondition); for (int i = 0; i < listAutomation.Count; i++) { if (listAutomation[i].Current.Name == "打印") { object patternObject; var pattern = listAutomation[i].TryGetCurrentPattern (InvokePattern.Pattern, out patternObject); ((InvokePattern)patternObject).Invoke(); } } Thread.Sleep(10000); }