税控接口 - 模拟录入
生活随笔
收集整理的這篇文章主要介紹了
税控接口 - 模拟录入
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
當時從其他稅控接口里面提取的JSON腳本,根據腳本實現了一份Delphi的源代碼。
JSON腳本:
[{"ClassName": "","Title": "開具增值稅專用發票","X": 150,"Y": 3,"ConfirmTitle": "","ConfirmClass": "","SI_Mode": 0,"ParentPath": "","InvType": 0,//表示增票"ClickPosition": {"ImportPoint": "-680, 25", //導入按鈕的位置"MImportPoint": "-680, 75",//手動導入按鈕的位置"BImportPoint": "-680, 95", //自動導入按鈕的位置"ListPoint":"-440,25", //清單按鈕的位置"InvZKPoint":"-380,25", //發票界面的折扣按鈕的位置"PricePoint":"-315,25","AddPoint":"-255,25","DeletePoint":"-195,25","PrintPoint": "-125, 25", //打印按鈕的位置"SelectPoint": "590, 29", //選擇單據按鈕的位置"ListZKPoint":"450,25"},"CtrlPosition": {"InvFirstPoint": { //發票界面的首行位置"PosIndex": 0,"Reference": "2","Position":"120,325","ParentTitle": "","ParentClass": ""},"InvNo": { //發票號碼"PosIndex": 16,"Reference": "2","Position":"730,53","ParentTitle": "","ParentClass": ""},"InvCode": { //發票代碼"PosIndex": 17,"Reference": "2","Position":"200,53","ParentTitle": "","ParentClass": ""},"PrintDate": { //打印日期"PosIndex": 15,"Reference": "2","Position":"770,100","ParentTitle": "","ParentClass": ""},"GFName": { //購方名稱"PosIndex": 38,"Reference": "2","Position":"230,135","ParentTitle": "","ParentClass": ""},"GFTaxNo": { //購方稅號"PosIndex": 33,"Reference": "2","Position":"230,157","ParentTitle": "","ParentClass": ""},"GFAddrTel": { //購方地址電話"PosIndex": 35,"Reference": "2","Position":"230,180","ParentTitle": "","ParentClass": ""},"GFBankAccount": { //購方銀行賬號"PosIndex": 31,"Reference": "2","Position":"230,203","ParentTitle": "","ParentClass": ""},"XFBankAccount": { //銷方銀行賬號"PosIndex": 22,"Reference": "2","Position":"235,553","ParentTitle": "","ParentClass": ""},"Memo": { //備注"PosIndex": 10,"Reference": "2","Position":"590,480","ParentTitle": "","ParentClass": ""},"FHR": { //復核人"PosIndex": 9,"Reference": "2","Position":"380,590","ParentTitle": "","ParentClass": ""},"SKR": { //收款人"PosIndex": 7,"Reference": "2","Position":"170,590","ParentTitle": "","ParentClass": ""}} }]delphi代碼:
function SetWindowCtrlText(aHandle: THandle; aValue: string): Boolean; beginSendMessage(aHandle, WM_SETTEXT, 0, integer(aValue)); end;procedure TFrmMain.btnInputClick(Sender: TObject); vari: integer;HR: THandle;ClassName, Title: string;sl: TSendInputHelper;InvFirstPoint: TPoint;current, BillDetail: TBillDetail;BillDetailList: TList<TBillDetail>;num2, millisecondsTimeout: integer; beginBillDetailList := TList<TBillDetail>.Create;for i := 1 to 6 dobeginBillDetail := TBillDetail.Create;BillDetail.SPMC := '商品名稱';BillDetail.SPGGXH := '規格';BillDetail.JLDW := '單位';BillDetail.sl := 1;BillDetail.DJ := 1000;BillDetail.JE := 1000;BillDetailList.Add(BillDetail);end;for i := 0 to JSON.Count - 1 dobeginClassName := JSON.Items[i].ItemByName('ClassName').AsString;Title := JSON.Items[i].ItemByName('Title').AsString;if (ClassName <> '') and (Title <> '') thenbeginHR := FindWindow(PWideChar(ClassName), PWideChar(Title));endelsebeginif ClassName <> '' thenbeginHR := FindWindow(PWideChar(ClassName), nil);endelsebeginHR := FindWindow(nil, PWideChar(Title));end;end;if HR <> 0 thenbeginBreak;end;end;if HR <> 0 thenbeginSetForegroundWindow(HR);SetText(JSON.Items[i], HR, 'GFName', '購方名稱');SetText(JSON.Items[i], HR, 'GFTaxNo', '1234567890123456');SetText(JSON.Items[i], HR, 'GFAddrTel', '地址電話');SetText(JSON.Items[i], HR, 'GFBankAccount', '銀行賬號');SetText(JSON.Items[i], HR, 'Memo', '備注');SetText(JSON.Items[i], HR, 'FHR', '復核人');SetText(JSON.Items[i], HR, 'SKR', '收款人');sl := TSendInputHelper.Create;tryInvFirstPoint := GetPoint(JSON.Items[i], 'InvFirstPoint');MoveAndClick(HR, InvFirstPoint);num2 := 0;millisecondsTimeout := 1000;for current in BillDetailList dobeginApplication.ProcessMessages;if (num2 <= BillDetailList.Count - 1) and (num2 > 0) thenbeginsl.AddDelay(millisecondsTimeout);sl.AddVirtualKey(VK_RETURN);sl.AddDelay(millisecondsTimeout);sl.AddVirtualKey(VK_HOME);sl.Flush;end;sl.AddText(current.SPMC);sl.AddVirtualKey(VK_TAB);sl.AddDelay(millisecondsTimeout);Delay(millisecondsTimeout);sl.AddText(current.SPGGXH);sl.AddVirtualKey(VK_TAB);sl.AddDelay(millisecondsTimeout);sl.AddText(current.JLDW);sl.AddVirtualKey(VK_TAB);sl.AddDelay(millisecondsTimeout);sl.AddText(CurrToStr(current.sl));sl.AddVirtualKey(VK_TAB);sl.AddDelay(millisecondsTimeout);sl.AddText(CurrToStr(current.DJ));sl.AddVirtualKey(VK_TAB);sl.AddDelay(millisecondsTimeout);sl.AddText(CurrToStr(current.JE));sl.AddVirtualKey(VK_RETURN);sl.AddDelay(millisecondsTimeout);sl.AddVirtualKey(VK_RETURN);sl.AddDelay(millisecondsTimeout);sl.AddVirtualKey(VK_RETURN);sl.Flush;inc(num2);end;finallyFreeAndNil(sl);end;end; end;procedure TFrmMain.FormCreate(Sender: TObject); beginJSON := TQJson.Create;JSON.Parse(JsonFile.Text); end;procedure TFrmMain.FormDestroy(Sender: TObject); beginFreeAndNil(JSON); end;function TFrmMain.GetPoint(aJSON: TQJson; aName: string): TPoint; varsPoint: string; beginsPoint := aJSON.ItemByPath('CtrlPosition.' + aName + '.Position').AsString;Result.X := StrToInt(Copy(sPoint, 1, Pos(',', sPoint) - 1));Result.Y := StrToInt(Copy(sPoint, Pos(',', sPoint) + 1, 10)); end;procedure TFrmMain.MoveAndClick(aHandle: THandle; p: TPoint); varrect: TRect;point: TPoint; beginGetWindowRect(aHandle, rect);point.X := rect.Left;point.Y := rect.Top;ClientToScreen(point);SetCursorPos(point.X + p.X, point.Y + p.Y);mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); end;function TFrmMain.SetText(aJSON: TQJson; aHandle: THandle; aName, aValue: string): Boolean; varp1, p, point: TPoint;sPoint: string;sl: TSendInputHelper;rect: TRect; beginGetWindowRect(aHandle, rect);GetCursorPos(p1);sl := TSendInputHelper.Create;trysPoint := aJSON.ItemByPath('CtrlPosition.' + aName + '.Position').AsString;p.X := StrToInt(Copy(sPoint, 1, Pos(',', sPoint) - 1));p.Y := StrToInt(Copy(sPoint, Pos(',', sPoint) + 1, 10));point.X := rect.Left;point.Y := rect.Top;ClientToScreen(point);SetCursorPos(point.X + p.X, point.Y + p.Y + 75);mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);sl.AddText(aValue);sl.Flush;finallySetCursorPos(p1.X, p1.Y);FreeAndNil(sl);end; end;?
轉載于:https://www.cnblogs.com/masg/p/9925350.html
總結
以上是生活随笔為你收集整理的税控接口 - 模拟录入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DNS反劫持的几种方式
- 下一篇: 大数据开源舆情分析系统-数据处理部分架构