Skip to content

Instantly share code, notes, and snippets.

@msorich
Last active May 8, 2019 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msorich/deb9bcb08c2721cf7fa2931f8f54170d to your computer and use it in GitHub Desktop.
Save msorich/deb9bcb08c2721cf7fa2931f8f54170d to your computer and use it in GitHub Desktop.
This Auto Hot Key script automates the task of exporting OLE embedded PDFs in FileMaker Pro .fp7 container fields and saves them to a specified folder/directory by using Adobe Acrobat reader on Windows platforms.
/*
*
* Description: This Auto Hot Key script automates the task of exporting OLE embedded PDFs in FileMaker Pro .fp7 container fields
* and saves them to a specified folder/directory by using Adobe Acrobat reader on Windows platforms. This script should be used with
* FileMaker Pro 11, but may work with versions that support the .fp7 file format.
*
*
* 2016 jul 31 msorich
* 2016 aug 01 msorich - adjusted Sleep values
*/
; # = Windows Key, ! Alt key + = Shift Key
; Abort!, hit the escape key to stop the script
Esc::ExitApp
#j::
Clipboard:=
WinActivate, FileMaker Pro Advanced
;go to record first by Showing Omitted and then Showing all records
;Send, !RI
;Send, !RW
;ExitApp
; number of records to loop thru
Loop 90
{
; go to the "primary key" or unique Id field
Send, {Tab}
; copy the field contents into the clipboard
Send, !ea
;Sleep 3000 2016 aug 01
Sleep 3000
Send, ^c
; Assigning the primary key field or unique Id value to the %PDFfileName% variable
PDFfileName:= Clipboard
;MsgBox %PDFfileName%
;Sleep 2000 2016 aug 01
Sleep 500
;Exit
; go to the container field
Send, {Tab}
;Sleep 2000 2016 aug 01
Sleep 1000
; "Open Acrobat Document" - the OLE PDF file in the FileMaker embedded in container field in the record
Send, ^{Enter}
;Sleep 3000 2016 aug 01
Sleep 3000
; Adobe Acrobat is now activated and we need to save the PDF File , Save As FA
Send, !fa
; Sometimes pauses are important so that AHK process doesn't get ahead of itself. This pause is for 3000 milliseconds or 3 seconds
Sleep 3000
; Get the class of the Adobe Acrobat "Save As" window, here's how to do it: https://autohotkey.com/docs/commands/WinGetClass.htm
/*
; A = "Active"
WinGetClass, class, A
MsgBox, The active window's class is "%class%".
*/
; This is the first Save As window when executing the save function in Adobe Acrobat
;WinActivate, ahk_class, AVL_AVDialog
;Send, {Tab 2}{Enter}
;Pause
;Sleep 1000
; This is the second "Save As" window when executing the save function in Adobe Acrobat. Here we also copy our PDF file name to the clipboard variable (%clipboard%) so we can save the PDF as the file name (or Primary Key).
; and then send the save command Ctrl+V
WinActivate, ahk_class, #32770
clipboard:= PDFfileName
Send, ^v
; Finally save the file using the primary key value. (Could send "S" here too)
Send, {Enter}
;Sleep 3000 2016 aug 01
Sleep 3000
; Close the Adobe Acrobat save PDF file window
WinActivate, ahk_class, AcrobatSDIWindow
Send, !fc
;Sleep 3000 2016 aug 01
Sleep 3000
; Go back to FileMaker Pro app Class is FMPRO11.0APP
WinActivate, FileMaker Pro Advanced
; FMP next record command
Send, !RGN
} ; end Loop
Return
@shwetameta
Copy link

Hi,

Your program is really very good.
But I m facing one issue, some of the container field files in my FileMaker solution are on a drive which is not accessible and I would like to skip these records if Opening the PDF gives issue.

How to handle this issue?

Thanks,
Shweta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment