Esempio n. 1
0
        /// <summary>
        /// 操作规格型号
        /// </summary>
        static void GuiGeXingHao()
        {
            var spflbmBar      = WinApi.FindWindow(null, "商品编码添加");
            var guiGebar       = WinApi.FindWindowEx(spflbmBar, IntPtr.Zero, null, "规格型号");
            var guiGeSelectBar = WinApi.FindWindowEx(spflbmBar, guiGebar, null, null);

            WinApi.ClickLocation(guiGeSelectBar, 10, 10);
            SendKeys.SendWait("{UP}");
            Thread.Sleep(1000);
            SendKeys.SendWait("{ENTER}");
            //int selected = WinApi.SendMessage(guiGeSelectBar, 0x014e, (IntPtr)0, null);

            Thread.Sleep(2000);

            var jianma = WinApi.FindWindowEx(spflbmBar, IntPtr.Zero, null, "简码");
            var temp   = WinApi.FindWindowEx(spflbmBar, jianma, null, null);

            temp = WinApi.FindWindowEx(spflbmBar, temp, null, null);
            temp = WinApi.FindWindowEx(spflbmBar, temp, null, null);
            //var selected1 = WinApi.SendMessage(temp, 0x014e, (IntPtr)1, null);
            WinApi.ClickLocation(temp, 10, 10);
            SendKeys.SendWait("{UP}");
            Thread.Sleep(1000);
            SendKeys.SendWait("{ENTER}");
        }
Esempio n. 2
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);
        }
Esempio n. 3
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();
        }
Esempio n. 4
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, "管理员"); //调整税率为传入税率
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
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");
        }
Esempio n. 7
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();
            //}
        }