Exemplo n.º 1
0
        /// <summary>
        /// 测试开票软件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button9_Click(object sender, EventArgs e)
        {
            var bar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");

            WinApi.ShowWindow(bar, 2); //最小
            Thread.Sleep(1000);
            WinApi.ShowWindow(bar, 3); //最大

            //bool flag = WinApi.SetForegroundWindow(bar);
            int fpglHw = WinApi.getHwByTitle((int)bar, "发票管理");



            int fpglHw1 = (int)WinApi.FindWindowEx((IntPtr)fpglHw, IntPtr.Zero, null, null);
            int fpglHw2 = (int)WinApi.FindWindowEx((IntPtr)fpglHw1, IntPtr.Zero, null, null);
            int fpglHw3 = (int)WinApi.FindWindowEx((IntPtr)fpglHw1, (IntPtr)fpglHw2, null, null);

            //WinApi.SetForegroundWindow(bar);
            Thread.Sleep(100);
            //点击发票填开
            WinApi.leftClick(fpglHw3);



            //KeyBoardDown((IntPtr)fpglHw1, 0x100);

            //return;


            Thread.Sleep(500);
            keybd_event(Keys.Down, 0, 0, 0);
            keybd_event(Keys.Down, 0, 2, 0);

            Thread.Sleep(500);
            keybd_event(Keys.Down, 0, 0, 0);
            keybd_event(Keys.Down, 0, 2, 0);

            Thread.Sleep(500);
            keybd_event(Keys.Down, 0, 0, 0);
            keybd_event(Keys.Down, 0, 2, 0);

            Thread.Sleep(500);
            keybd_event(Keys.Enter, 0, 0, 0);
            keybd_event(Keys.Enter, 0, 2, 0);

            Thread.Sleep(1000);
            var form1 = WinApi.FindWindow(null, "发票号码确认");

            Thread.Sleep(1000);
            var confirm = WinApi.FindWindowEx(form1, IntPtr.Zero, null, "确认");

            WinApi.leftClick((int)confirm);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 税盘最大化最小化
 /// </summary>
 public static void test1()
 {
     var bar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");
     Thread.Sleep(1000);
     WinApi.ShowWindow(bar, 2);
     Thread.Sleep(1000);
     WinApi.ShowWindow(bar, 3);
     Thread.Sleep(1000);
     WinApi.ShowWindow(bar, 2);
     Thread.Sleep(1000);
     WinApi.ShowWindow(bar, 3);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获取窗体相对位置,点击该位置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button7_Click(object sender, EventArgs e)
        {
            var hxBar   = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");
            var toolBar = WinApi.FindWindowEx(hxBar, IntPtr.Zero, null, null);

            WinApi.ClickLocation(toolBar, 40, 29);
            Thread.Sleep(1000);
            WinApi.ClickLocation(toolBar, 110, 29);
            Thread.Sleep(1000);
            //WinApi.ClickLocation(toolBar, 190, 29);
            var flag = WinApi.ClickLocation(toolBar, 190, 29);
            //var flag1 = WinApi.ClickLocation(ptrTaskbar, 421, 89);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取窗体句柄-获取窗体title-改变窗体title
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            IntPtr ptrTaskbar = WinApi.FindWindow(null, "Form1Text");

            if (ptrTaskbar == IntPtr.Zero)
            {
                MessageBox.Show("No windows found!");
                return;
            }
            var title = GetTitle(ptrTaskbar);

            SetTitle(ptrTaskbar);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取窗体大小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button5_Click(object sender, EventArgs e)
        {
            IntPtr ptrTaskbar = WinApi.FindWindow(null, "Form1Text");

            if (ptrTaskbar == IntPtr.Zero)
            {
                MessageBox.Show("No windows found!");
                return;
            }
            WinApi.NativeRECT rect;
            HandleRef         ptrT = new HandleRef(null, ptrTaskbar);

            WinApi.GetWindowRect(ptrT, out rect);
            var width = rect.right - rect.left;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 点击成品油测试
        /// </summary>
        public static void test2()
        {
            var bar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");
            var barChild = WinApi.FindWindowEx(bar, IntPtr.Zero, null, null);//获取句柄成功

            for (var i = 0; i < 10; i++)
            {
                WinApi.ClickLocation(barChild, 30, 28);
                Thread.Sleep(1000);
                WinApi.ClickLocation(barChild, 90, 28);
                Thread.Sleep(1000);
                //var childone = WinApi.FindWindowEx(barChild, IntPtr.Zero, null, null);
            }

            int fpglHw = WinApi.getHwByTitle((int)bar, "成品油");//这里改下标题就好了

        }
Exemplo n.º 7
0
        /// <summary>
        /// 发送文本消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //获取主窗体句柄
            //WindowsForms10.Window.8.app.0.141b42a_r16_ad1
            IntPtr ptrTaskbar = WinApi.FindWindow(null, "Form1Text");

            if (ptrTaskbar == IntPtr.Zero)
            {
                MessageBox.Show("No windows found!");
                return;
            }
            IntPtr ccPtr = IntPtr.Zero;
            //获取窗体中"textBox1"按钮
            IntPtr ptrStartTxt = WinApi.FindWindowEx(ptrTaskbar, ccPtr, "WindowsForms10.EDIT.app.0.141b42a_r16_ad1", null);
            var    title       = GetTitle(ptrStartTxt);

            sendMessage(ptrStartTxt);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 临时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button13_Click(object sender, EventArgs e)
        {
            //关闭窗体
            var bar = WinApi.FindWindow(null, "开具增值税电子普通发票");

            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(1000);
                var closeBar = WinApi.FindWindow(null, "SysMessageBox");
                var noBar    = WinApi.getHwByTitle((int)closeBar, "是");
                WinApi.leftClick(noBar);
                //MessageBox.Show($"closeBar:{closeBar}; noBar:{noBar}");
            });
            SendMessage(bar, 0x10, 0, 0);
            Thread.Sleep(100);
            //MessageBox.Show("哈哈~,关闭开具增值税电子普通发票fail");
            //var closeBar = WinApi.FindWindow(null, "SysMessageBox");
            //var noBar = WinApi.FindWindow(null, "否");
        }
Exemplo n.º 9
0
        /// <summary>
        /// 查找子窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            IntPtr ptrTaskbar = WinApi.FindWindow(null, "Form1Text");

            if (ptrTaskbar == IntPtr.Zero)
            {
                MessageBox.Show("No windows found!");
                return;
            }
            IntPtr child = IntPtr.Zero;
            int    i     = 0;

            do
            {
                child = WinApi.FindWindowEx(ptrTaskbar, child, null, null);
                var title = GetTitle(child);
                TxtResult.Text += $"控件{i}:{title}\r\n";
                var flag = child.Equals(IntPtr.Zero);
                i++;
            } while (!child.Equals(IntPtr.Zero));
        }
Exemplo n.º 10
0
        public static void BoardChooseSuccess()
        {
            var bar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");

            WinApi.ShowWindow(bar, 2);
            Thread.Sleep(100);
            WinApi.ShowWindow(bar, 3);

            //bool flag = WinApi.SetForegroundWindow(bar);
            int fpglHw = WinApi.getHwByTitle((int)bar, "发票管理");



            int fpglHw1 = (int)WinApi.FindWindowEx((IntPtr)fpglHw, IntPtr.Zero, null, null);
            int fpglHw2 = (int)WinApi.FindWindowEx((IntPtr)fpglHw1, IntPtr.Zero, null, null);
            int fpglHw3 = (int)WinApi.FindWindowEx((IntPtr)fpglHw1, (IntPtr)fpglHw2, null, null);
            WinApi.SetForegroundWindow(bar);
            Thread.Sleep(100);
            //点击发票填开
            WinApi.leftClick(fpglHw3);
            Thread.Sleep(500);
            keybd_event(Keys.Down, 0, 0, 0);
            keybd_event(Keys.Down, 0, 2, 0);
            for (var i = 0; i < 10; i++)
            {
                Thread.Sleep(500);
                keybd_event(Keys.Down, 0, 0, 0);
                keybd_event(Keys.Down, 0, 2, 0);
                Thread.Sleep(500);
                keybd_event(Keys.Down, 0, 0, 0);
                keybd_event(Keys.Down, 0, 2, 0);
                Thread.Sleep(500);
                keybd_event(Keys.Up, 0, 0, 0);
                keybd_event(Keys.Up, 0, 2, 0);
                Thread.Sleep(500);
                keybd_event(Keys.Up, 0, 0, 0);
                keybd_event(Keys.Up, 0, 2, 0);
                Thread.Sleep(500);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 点击按钮操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            //获取主窗体句柄
            //WindowsForms10.Window.8.app.0.141b42a_r16_ad1
            IntPtr ptrTaskbar = WinApi.FindWindow(null, "Form1Text");

            if (ptrTaskbar == IntPtr.Zero)
            {
                MessageBox.Show("No windows found!");
                return;
            }
            //获取窗体中"button1"按钮
            IntPtr ptrStartBtn = WinApi.FindWindowEx(ptrTaskbar, IntPtr.Zero, null, "button1");

            if (ptrStartBtn == IntPtr.Zero)
            {
                MessageBox.Show("No button found!");
                return;
            }
            SendMessage(ptrStartBtn, 0xF5, 0, 0);
            Thread.Sleep(2000);
            SendMessage(ptrTaskbar, 0x10, 0, 0);//关闭窗体
        }