🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.capture
Article #193

Re: How to start PaperCapture by batch-script

#193
From: Lauren_Sandbek
Date: Fri, 30 Jun 2006 12:57
96 lines
5043 bytes
I have figured this one out. If you're interested, the resolution is posted at: <http://www.autohotkey.com/forum/viewtopic.php?p=66003#66003>

I appreciate it anyway.

My final modified script is below:

;	Required: Adobe Acrobat Professional 7.08
;	Settings: Change Adobe Acrobat to be default program to open TIF files | create OCR directory under C: and create an IN, OUT and
;		ARCHIVE folder directly under this | turn off all pop up windows in Adobe by clicking on "dont show at startup" when they appear |
;		put an instance of the script in the Startup folder under Start -->Programs -->Startup

#Persistent ;keeps script permanently running
#SingleInstance ignore ;does not allow multiple instances and does not allow new instances to replace old instances
SetTimer, ProcessInbox, 250 ;Calls the ProcessInbox Label every 250 ms

ProcessInbox:
  UnScannedPath=C:\OCR\IN\*.tif ;set this variable to your unrendered tifs's
  ScannedPath=C:\OCR\OUT\ ;set this variable to the dir of your scanned pdf's
  DestinationPath=C:\OCR\ARCHIVE ;set this variable to the dir of your archived TIF files

ifExist, %UnScannedPath% ;check to see if any files exist in the IN folder
  {
    Loop,%UnScannedPath%, , 1 ;Loop through all files, recursing into subfolders.
    {
      ;parse filename
      StringSplit,OutFile,A_LoopFileFullPath,\ ;extract filename
      StringLeft, OutFilePDF, OutFile4, StrLen(OutFile4) - 4 ;take off .tif
      CurrentFile=%OutFilePDF%.pdf
      x:=0 ;array counter (could have also used a_index)

;check to see if file exists and add a version number to it if it does.
      Loop
      {
         if x=0 ;first time in loop
	 {
	 ifNotExist, %ScannedPath%%OutFilePDF%*
	 	 {
			 OutFilePDF=%OutFilePDF%.pdf
              break ;file doesn't exist in destination folder - proceed in adding it
		 }
	 }
	 else
	 {
	 ifNotExist, %ScannedPath%%OutFilePDF%_%x%*
		 {
			 OutFilePDF=%OutFilePDF%_%x%.pdf
              break ;file exists in destination folder - proceed in adding it and appending the appropriate version to the end
		 }
         }
	 x:=x+1 ;Add one to file version number
       }

Run %A_LoopFileFullPath% ;start Adobe with the requested file
       winwait,Adobe

Send, !f ;switch to Files Menu
       Send, {RIGHT 4} ;point to Document menu
       Send, {DOWN 5}{RIGHT}{ENTER} ;point to Recognize Text Using OCR/Start in the Document menu
       WinWait, Recognize Text ;Wait for Recognize Text Window to open
       Send {UP}{ENTER} ;all pages
       WinWait, Adobe Acrobat Professional - [%OutFilePDF%],,5

Send +^s ;send save keystroke (shift+ctrl+s)
       WinMinimize, Adobe Acrobat Professional - [%CurrentFile%] ;Minimize Adobe - necessary for this script to work properly

SetTimer, WatchForErrorWindow, 50 ;look for Error window every 50 ms
       WinWait, Save As
       SetTimer, WatchForErrorWindow, off

WinRestore, Adobe Acrobat Professional - [%CurrentFile%] ;Restore Adobe
       WinActivate, Save As ;Activate 'Save As' window

Send %ScannedPath%%OutFilePDF%{ENTER} ;send output filename (OUT folder)
       Send ^q ;close Adobe

WinWaitClose, Adobe Acrobat Professional - [%CurrentFile%] ;wait until Adobe is closed and start with the next pdf
       FileMove, %A_LoopFileFullPath%, %DestinationPath% ;move TIF file from IN folder to ARCHIVE folder
    }
  }
  return

WatchForErrorWindow:
  IfWinNotExist, Adobe Acrobat,, Adobe Acrobat Professional - [%CurrentFile%]
    return ;do nothing if Error window does not exist
  ;Otherwise:
  {
    WinRestore, Adobe Acrobat Professional - [%CurrentFile%] ;Restore Adobe Window
    WinActivate, Adobe Acrobat,, Adobe Acrobat Professional - [%CurrentFile%] ;Activate Error Window
    WinWaitActive, Adobe Acrobat,,, Adobe Acrobat Professional - [%CurrentFile%]
	Send, {ENTER}{ENTER} ;Hit OK on Error window to continue processing
	WinActivate, Adobe Acrobat Professional - [%CurrentFile%] ;Activate Adobe Window
	WinWaitActive, Adobe Acrobat Professional - [%CurrentFile%]
    Send +^s ;send save keystroke (shift+ctrl+s) ;Save Again (previous save was lost with Error popping up)
    WinMinimize, Adobe Acrobat Professional - [%CurrentFile%] ;Minimize Adobe - necessary for this script to work properly
  }
  return
Technical Details
Message-ID: <3bbe7163.5@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!syros.belnet.be!news.belnet.be!news.stben.net!webcrossing
References: <3bbe7163.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f84b4,2fc9ebfcfbdfca2f
X-Google-Attributes: gidf84b4,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Lauren_Sandbek@adobeforums.com
Newsgroups: adobe.acrobat.capture
Subject: Re: How to start PaperCapture by batch-script
Message-ID: <3bbe7163.5@webcrossing.la2eafNXanI>
Date: Fri, 30 Jun 2006 05:57:24 -0700
References: <3bbe7163.-1@webcrossing.la2eafNXanI>
Lines: 124
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!syros.belnet.be!news.belnet.be!news.stben.net!webcrossing