/// <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); }
/// <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, "成品油");//这里改下标题就好了 }
/// <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, "否"); }
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); } }