Ejemplo n.º 1
0
        //填写税收分类编码--填写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");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 操作航信自定义报错弹框
        /// </summary>
        static void OperatorCustomer()
        {
            var custoBar    = WinApi.FindWindow(null, "CusMessageBox");
            var editControl =
                UiaHelper.GetUIAutomation().ElementFromHandle(custoBar).FindFirst(UIAutomationClient.TreeScope.TreeScope_Descendants,
                                                                                  UiaHelper.GetUIAutomation().CreatePropertyCondition(UIA_PropertyIds.UIA_AutomationIdPropertyId, "rtbDescript"));

            var pt = (IUIAutomationValuePattern)editControl.GetCurrentPattern(UIA_PatternIds.UIA_ValuePatternId);

            Console.WriteLine(pt.CurrentValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 查找自动导入按钮
        /// </summary>
        static void ZiDongDaoRu()
        {
            var  bar      = WinApi.FindWindow(null, "开具增值税普通发票");
            var  list     = WinApi.EnumChilWindowsIntptr(bar);
            var  childBar = list[list.Count - 1];
            RECT rect;
            var  handler = new HandleRef(null, childBar);
            var  flag    = WinApi.GetWindowRect(handler, out rect);

            WinApi.ClickLocation(childBar, rect.right - rect.left - 690, 25);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取卷票明细中的错误
        /// </summary>
        static void JuanPiaomingxi()
        {
            var    bar   = WinApi.FindWindow(null, "SysMessageBox");
            IntPtr child = WinApi.FindWindowEx(bar, IntPtr.Zero, null, null);

            for (var i = 0; i < 4; i++)
            {
                child = WinApi.FindWindowEx(child, IntPtr.Zero, null, null);
            }
            StringBuilder sb = new StringBuilder();

            WinApi.GetWindowText(child, sb, 1024);
            Console.WriteLine(sb.ToString());
        }
Ejemplo n.º 7
0
        /// <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---测试");
        }
Ejemplo n.º 8
0
        /// <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);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 尚未成功
        /// </summary>
        static void GetText()
        {
            var bar    = WinApi.FindWindow(null, "Form1Text");
            var btnBar = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "button1");
            var txtBar = WinApi.FindWindowEx(bar, btnBar, null, null);

            StringBuilder sb = new StringBuilder();

            WinApi.GetDlgItemText(bar, (int)txtBar, sb, 255);
            Console.WriteLine(sb.ToString());

            WinApi.GetWindowText(txtBar, sb, 255);//获取标题
            Console.WriteLine(sb.ToString());
        }
Ejemplo n.º 10
0
        static void SendKey()
        {
            var bar    = WinApi.FindWindow(null, "Form1Text");
            var btnBar = WinApi.FindWindowEx(bar, IntPtr.Zero, null, "button1");
            var txtBar = WinApi.FindWindowEx(bar, btnBar, null, null);

            //WinApi.SendKey(txtBar, KeySnap.VK_CAPITAL);
            //Thread.Sleep(500);
            WinApi.SendKey(txtBar, KeySnap.VK_A);
            Thread.Sleep(1000);
            WinApi.SendKey(txtBar, KeySnap.VK_B);
            Thread.Sleep(1000);
            WinApi.SendKey(txtBar, KeySnap.VK_C);
        }
Ejemplo n.º 11
0
        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, "管理员"); //调整税率为传入税率
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 电票 添加 减少按钮
        /// </summary>
        static void SearchAddLess()
        {
            var bar    = WinApi.FindWindow(null, "开具增值税电子普通发票");
            var child  = WinApi.FindWindowEx(bar, IntPtr.Zero, null, null);
            var child1 = WinApi.FindWindowEx(child, IntPtr.Zero, null, null);
            var child2 = WinApi.FindWindowEx(child, child1, null, null);

            Console.WriteLine($"bar:{bar},child:{child},child1:{child1},child2:{child2}");
            RECT      rect;
            HandleRef ptrT = new HandleRef(null, child2);

            WinApi.GetWindowRect(ptrT, out rect);
            for (var i = 0; i < 4; i++)
            {
                WinApi.ClickLocation(child2, rect.right - rect.left - 195, 25); //减少行
                Thread.Sleep(1000);
                WinApi.ClickLocation(child2, rect.right - rect.left - 195, 25); //减少
                Thread.Sleep(1000);
                WinApi.ClickLocation(child2, rect.right - rect.left - 250, 25); //减少
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
        /// <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);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 截图测试
        /// </summary>
        static void JieTuCeShi()
        {
            var bar    = WinApi.FindWindow(null, "开具增值税普通发票");
            var child  = WinApi.FindWindowEx(bar, IntPtr.Zero, null, null);
            var child1 = WinApi.FindWindowEx(child, IntPtr.Zero, null, null);
            var child2 = WinApi.FindWindowEx(child, child1, null, null);
            //Console.WriteLine($"bar:{bar},child:{child},child1:{child1},child2:{child2}");
            var map = WinApi.GetWindowCapture(child2);

            Color destColor1 = Color.FromArgb(156, 175, 51); //
            Color destColor2 = Color.FromArgb(240, 132, 60); //
            bool  isNoTax    = false;
            var   X          = 0;

            for (var i = map.Width - 350; i < map.Width - 310; i++)//310,350,10,40
            {
                for (var j = 11; j < 39; j++)
                {
                    var color = map.GetPixel(i, j);
                    if (color.Equals(destColor1))
                    {
                        Console.WriteLine($"no tax success,(x:{i},y:{j})");
                        isNoTax = true;
                        X       = i;
                        break;
                    }
                    if (color.Equals(destColor2))
                    {
                        Console.WriteLine($"tax success,(x:{i},y:{j})");
                        isNoTax = false;
                        X       = i;
                        break;
                    }
                }
            }
            if (!isNoTax)
            {
                WinApi.ClickLocation(child2, X + 20, 25);//点击价格,不含税
            }
            Console.WriteLine("=========================================================");
            //WinApi.ClickLocation(child2, X + 20, 25);


            for (var i = 0; i < map.Width; i++)
            {
                var pixel = map.GetPixel(i, 25);

                var r3 = (pixel.R - destColor1.R) / 256.0;
                var g3 = (pixel.G - destColor1.G) / 256.0;
                var b3 = (pixel.B - destColor1.B) / 256.0;

                var diff = Math.Sqrt(r3 * r3 + g3 * g3 + b3 * b3);
                if (diff <= 0.05)
                {
                    Console.WriteLine($"success,(x:{i},y:25)");
                }
            }

            //map.GetPixel();
            //map.Save($"{DateTime.Now.Ticks}.png");
        }
Ejemplo n.º 16
0
        static void SearchInputFail()
        {
            WinApi.GetWindowRect(new HandleRef(null, (IntPtr)1901104), out var rectbefore);
            WinApi.MoveWindow((IntPtr)1901104, 10, 10, 3000, 2000, true);
            WinApi.GetWindowRect(new HandleRef(null, (IntPtr)1901104), out var rectbeafter);



            //Thread.Sleep(60000);
            //var formBar = WinApi.FindWindow(null, "票易通发票助手");
            var winBar      = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190728");
            var child1s     = WinApi.EnumChildWindowsCallback(winBar);
            var HmSearchBar = child1s.Find(b => b.szWindowName == "选择发票号码查询" || b.szTextName == "选择发票号码查询").hWnd;
            var childs      = WinApi.FindChildInfo(HmSearchBar);
            var bar         = childs.Find(b => b.szWindowName == "报送状态" || b.szTextName == "报送状态").hWnd;

            //WinApi.ClickLocation(bar, 5, 15);
            WinApi.ClickLocation(bar, 5, 15);

            Thread.Sleep(1000);

            //198352,
            var editControl = UiaHelper.GetUIAutomation().ElementFromHandle(winBar).FindFirst(UIAutomationClient.TreeScope.TreeScope_Descendants,
                                                                                              UiaHelper.GetUIAutomation().CreatePropertyCondition(UIA_PropertyIds.UIA_AutomationIdPropertyId, "198352"));


            //var editControls = UiaHelper.GetUIAutomation().ElementFromHandle(winBar).FindAll(UIAutomationClient.TreeScope.TreeScope_Descendants,
            //    UiaHelper.GetUIAutomation().CreatePropertyCondition(
            //        UIA_PropertyIds.UIA_ControlTypePropertyId,UIA_ControlTypeIds.UIA_EditControlTypeId));

            //for (var i = 0; i < editControls.Length; i++)
            //{
            //    var element = editControls.GetElement(i);
            //    var pt = (IUIAutomationValuePattern)element.GetCurrentPattern(UIA_PatternIds.UIA_ValuePatternId);
            //    if (i == 0)
            //        pt.SetValue("chenchangchenchang");
            //    Console.WriteLine($"CurrentName:{element.CurrentName} ,currentValue:{pt.CurrentValue}");
            //}

            //var child = UiaHelper.GetUIAutomation().ElementFromHandle(winBar).FindAll(
            //    UIAutomationClient.TreeScope.TreeScope_Children,
            //    UiaHelper.GetUIAutomation().CreateTrueCondition());
            //for (var i = 0; i < child.Length; i++)
            //{
            //    Console.WriteLine(child.GetElement(i).CurrentName);
            //}


            //var elements = child.GetElement(1).FindAll(UIAutomationClient.TreeScope.TreeScope_Children,
            //    UiaHelper.GetUIAutomation().CreateTrueCondition());
            //for (var i = 0; i < elements.Length; i++)
            //{
            //    Console.WriteLine(elements.GetElement(i).CurrentName);
            //}

            //var elements = UiaHelper.GetUIAutomation().ElementFromHandle(bar).FindAll(
            //    UIAutomationClient.TreeScope.TreeScope_Descendants,
            //    UiaHelper.GetUIAutomation().CreateTrueCondition());
            //for (var i = 0; i < elements.Length; i++)
            //{
            //    var ele = elements.GetElement(i);
            //    Console.WriteLine(ele.CurrentName);
            //}


            //var element = UiaHelper.GetUIAutomation().ElementFromHandle(bar).FindFirst(
            //    UIAutomationClient.TreeScope.TreeScope_Children,
            //    UiaHelper.GetUIAutomation().CreateTrueCondition());
            //if (element != null)
            //{
            //    var pt = (IUIAutomationLegacyIAccessiblePattern) element.GetCurrentPattern(
            //        patternId: UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
            //    pt.DoDefaultAction();
            //}
        }