/// <summary> /// 改变文本文件的内容 /// </summary> static void ChangeText() { var bar = WinApi.FindWindow(null, "Form1Text"); var btnBar = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "button1"); var txtBar = WinApi.FindWindowEx(bar, btnBar, null, null); WinApi.SendMessage(txtBar, 0x0C, IntPtr.Zero, "AKKJJCCBBDDEE"); //对文本框进行赋值 }
/// <summary> /// 根据索引选中下拉框 /// </summary> static void SelectTaxDemo() { var bar = WinApi.FindWindow(null, "商品编码添加"); var child = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "*税率"); var child1 = WinApi.FindWindowEx(bar, child, null, null); Console.WriteLine($"bar:{bar},child:{child},child1:{child1}"); //通过索引设置下拉框选项 int selected = WinApi.SendMessage(child1, 0x014e, (IntPtr)6, ""); }
//填写税收分类编码--填写text文本 static void TianXieShuiShouFenLeiBianMa() { var spflbmBar = WinApi.FindWindow(null, "商品编码添加"); var ssflName = WinApi.FindWindowEx(spflbmBar, IntPtr.Zero, null, "税收分类名称"); var temp1 = WinApi.FindWindowEx(spflbmBar, ssflName, null, null); var temp2 = WinApi.FindWindowEx(temp1, IntPtr.Zero, null, null); var ssflBar = WinApi.FindWindowEx(temp1, temp2, null, null); //获取税收分类编码句柄 //Console.WriteLine($"spflbmBar:{spflbmBar},child:{child},child1:{child1},child2:{child2},child3:child3"); WinApi.SendMessage(ssflBar, 0x0C, IntPtr.Zero, "110"); }
/// <summary> /// 专票地址信息填写 /// </summary> static bool ZhuanPiaoInfo() { string pageName = "开具增值税专用发票"; var bar = WinApi.FindWindow(null, pageName); if (bar == IntPtr.Zero) { return(false); } var list = WinApi.EnumChilWindowsIntptr(bar).Select(ptr => (int)ptr).ToList(); //var grandparent = WinApi.GetParent((IntPtr) list[list.Count - 1]); //var parent = (int)WinApi.FindWindowEx(grandparent, IntPtr.Zero, null, null); //var parent2 = (int)WinApi.FindWindowEx((IntPtr)parent, IntPtr.Zero, null, null); var list2 = WinApi.FindChildBar((IntPtr)list[2]); var list3 = WinApi.FindChildBar(list2[19]); var list4 = WinApi.FindChildBar(list2[21]); for (var i = 0; i < list3.Count; i++) { WinApi.SendMessage(list3[i], 0x0C, IntPtr.Zero, "6217920170878354"); StringBuilder sb = new StringBuilder(); //获取文本 WinApi.GetWindowTextW(list3[i], sb, 255); var str = sb.ToString(); } for (var i = 0; i < list4.Count; i++) { WinApi.SendMessage(list4[i], 0x0C, IntPtr.Zero, "xinjiapo 15721527020"); } var accountBar1 = WinApi.FindWindowEx((IntPtr)list2[list2.Count - 4], IntPtr.Zero, null, null); var accountBar2 = WinApi.FindWindowEx((IntPtr)list2[list2.Count - 4], accountBar1, null, null); //WinApi.SendMessage(accountBar, 0x0C, IntPtr.Zero, "6217720678878325"); if (list == null || list.Count < 37) { return(false); } WinApi.SendMessage((IntPtr)list[list.Count - 5], 0x0C, IntPtr.Zero, "shanghai..."); Thread.Sleep(500); //WinApi.SendMessage((IntPtr)list[37], 0x0C, IntPtr.Zero, "6217720678878325"); WinApi.SendMessage((IntPtr)list[list.Count - 9], 0x0C, IntPtr.Zero, "6217720678878325"); return(true); }
/// <summary> /// 卷票折扣功能 /// </summary> static void JuanPiaoZheKou() { Thread.Sleep(3000); var bar = WinApi.FindWindow(null, "开具增值税普通发票(卷票)"); var child = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "FPtiankai_new"); var child1 = WinApi.FindWindowEx(child, IntPtr.Zero, null, null); var child2 = WinApi.FindWindowEx(child, child1, null, null); RECT rect; HandleRef ptrT = new HandleRef(null, child2); WinApi.GetWindowRect(ptrT, out rect); WinApi.ClickLocation(child2, rect.right - rect.left - 290, 25); //点击折扣 Thread.Sleep(500); var bar1 = WinApi.FindWindow(null, "添加折扣行"); var list = WinApi.EnumChilWindowsIntptr(bar1).Select(i => (int)i).ToList(); if (list == null || list.Count < 7) { return; } WinApi.SendMessage((IntPtr)list[6], 0x0C, IntPtr.Zero, "2.5"); //Thread.Sleep(1000); //WinApi.keybd_event(Keys.Tab, 0, 0, 0); //Thread.Sleep(1000); //WinApi.keybd_event(Keys.Tab, 0, 0, 0); //Thread.Sleep(1000); //WinApi.keybd_event(Keys.Tab, 0, 0, 0); //Thread.Sleep(1000); //WinApi.keybd_event(Keys.Enter, 0, 0, 0); Thread.Sleep(1000); WinApi.PostMessage((IntPtr)list[4], 0x00F5, 0, 0); //WinApi.LeftClick((IntPtr)list[4]); //WinApi.SendKey((IntPtr)list[4], KeySnap.VK_ENTER); //WinApi.ClickLocation((IntPtr) list[4],1,1); Console.ReadKey(); }
/// <summary> /// 红冲专票-备注 /// </summary> static void HongChongRemark() { var bar = WinApi.FindWindow(null, "开具增值税专用发票"); var list = WinApi.EnumChilWindowsIntptr(bar); for (var i = 0; i < list.Count; i++) { if (list[i] == (IntPtr)525010) { Console.WriteLine(i); } } WinApi.SendMessage(list[11], 0x0C, IntPtr.Zero, "备注---chenchang---测试"); }
/// <summary> /// 最大最小化 /// </summary> static void ShowWindow() { var winBar = WinApi.FindWindow(null, "Form1Text"); var childs = WinApi.FindChildBar(winBar); WinApi.SendMessage(childs[childs.Count - 1], 0x0C, IntPtr.Zero, "chenchang"); for (var i = 0; i < 1; i++) { WinApi.ShowWindow(winBar, 2); //最小 Thread.Sleep(1000); WinApi.ShowWindow(winBar, 3); //最大 Thread.Sleep(1000); } }
static void JuanPiaoLuoJi() { var bar = WinApi.FindWindow(null, "开具增值税普通发票(卷票)"); var child = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "FPtiankai_new"); var child1 = WinApi.FindWindowEx(child, IntPtr.Zero, null, null); var child2 = WinApi.FindWindowEx(child, child1, null, null); RECT rect; HandleRef ptrT = new HandleRef(null, child2); WinApi.GetWindowRect(ptrT, out rect); for (var i = 0; i < 5; i++) { WinApi.ClickLocation(child2, rect.right - rect.left - 230, 25); //增加行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 230, 25); //增加行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 230, 25); //增加行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 230, 25); //增加行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 170, 25); //减少行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 170, 25); //减少行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 170, 25); //减少行 Thread.Sleep(1000); WinApi.ClickLocation(child2, rect.right - rect.left - 170, 25); //减少行 Thread.Sleep(1000); } //收款员测试 var cc1 = (int)WinApi.FindWindowEx(child1, IntPtr.Zero, null, null); //var cc2 = (int)WinApi.FindWindowEx((IntPtr)cc1, IntPtr.Zero, null, null); var fpdm = (int)WinApi.FindWindowEx((IntPtr)cc1, IntPtr.Zero, null, "发票代码:"); var cc3 = (int)WinApi.FindWindowEx((IntPtr)cc1, (IntPtr)fpdm, null, null); var cc4 = (int)WinApi.FindWindowEx((IntPtr)cc1, (IntPtr)cc3, null, null); var cc5 = (int)WinApi.FindWindowEx((IntPtr)cc4, IntPtr.Zero, null, null); WinApi.SendMessage((IntPtr)cc4, 0x0C, (IntPtr)0, "管理员"); //调整税率为传入税率 }
/// <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); } }