program PatentApplicationSearch; // Sample script searches for a patent application, // extracts table data to csv file and downloads a // claim PDF file. // You will need to enter patent application ID below Const ExportFile = 'c:\Patent.csv'; ExportPDF = 'c:\claims.pdf'; var i : integer; bSearched, bDownloadFile, bSaveFile1, bSaveFile2 : boolean; procedure OnTimer; begin SetTimer(False, 0); if (bSaveFile1) then begin bSaveFile1 := False; MouseClickXy(529, 145); SetTimer(True, 7000); bSaveFile2 := True; end; if (bSaveFile2) then begin bSaveFile2 := False; WaitSendKeyPress('ALT+S', 5000, 1); WaitSendString(ExportPDF, 10000, 1); WaitSendKeyPress('ENTER', 15000, 1); // close web browser WaitSendKeyPress('ALT+F4', 22000, 1); // close web browser WaitSendKeyPress('ALT+F4', 25000, 1); end; end; procedure OnDocumentComplete(URL : string); begin if IsPartOf('http://portal.uspto.gov/external/portal/', URL) and (bDownloadFile) then begin bDownloadFile := False; ClickHyperLink('Claims'); SetTimer(True, 8000); bSaveFile1 := True; end else if IsPartOf('http://portal.uspto.gov/external/portal/', URL) and (bSearched) then begin bSearched := False; for i := 0 to 8 do begin WriteToLog(ExportFile, '', GetTableCell(23, i, 1)); end; // Goto Image File Wrapper Tab ExecuteWebScript('javascript:submitTab("ifwtab")', 'JavaScript'); bDownloadFile := True; end else if IsPartOf('http://portal.uspto.gov/external/portal/pair', URL) then begin // Enter application number below Fill('dosnum', ''); ClickButtonValue('SEARCH'); bSearched := True; end else if IsPartOf('http://portal.uspto.gov/external/portal/home', URL) then begin ClickHyperLink('Public PAIR >'); end; end; begin bSearched := False; bDownloadFile := False; bSaveFile1 := False; bSaveFile2 := False; DeleteFile(ExportFile); SetExecuteBrowser('IE'); Navigate('http://portal.uspto.gov/external/portal/home'); end.