When I use a msgbox the variables are correct and present. When I use a smaller db the information is sent correctly. Should I be using a WinWaitClose?
update: I used winwaitclose and problem resolved.
Code: Select all
; ------------------------------------------------------------------------------------------------------------------------------
; ----- This script performs the following actions -----
; ----- -----
; ----- 1. Sets the title matching mode for a partial beginning string -----
; ----- 2. Checks for the existence of the window for EndNote X7 -, then activates that window -----
; ----- 3. Isolates and puts in a variable the name of the open library -----
; ----- 4. Backs up the current library to an endnote library folder of your choosing -----
; ----- 5. Names the backup file (with extension .enlx) with today's date and time and the name of the library -----
; ----- -----
; ------------------------------------------------------------------------------------------------------------------------------
; ----- -----
; ----- This script was written by Thomas Zucker-Scharff -----
; ----- -----
; ------------------------------------------------------------------------------------------------------------------------------
Return
#!b:: ; assign [Win]+[ALT]+b to backup script
MsgBox, Have you opened your library yet, if not please do so, then click Okay.
; *********************************************************
; ***** get shared variables using GuiVar library *****
; *********************************************************
MyFolder := GuiVar_Get("SelectedFolder")
MyFile := GuiVar_Get("NowText")
BaseFileName := GuiVar_Get("BaseFileName")
Destination := GuiVar_Get("Destination")
; *********************************************************
FileSelectFolder, MyFolder,,6,Select a Destination Folder ; ask for preferred destination folder
datetime = %A_Year%%A_MM%%A_DD%_%A_Hour%%A_Min%
FullFileName = %MyFolder%\%datetime%
; **************************************************************
; ***** Determine if chosen directory is folder or drive *****
; ***** If it is a directory put extra \ in, else not *****
; **************************************************************
slashes = \\
ifInString FullFileName, %slashes%
{
FullFileName = %Myfolder%%datetime%
}
Else
{
FullFileName = %MyFolder%\%datetime%
}
; **************************************************************
SetTitleMatchMode,1 ; title must begin with String
IfWinExist,EndNote X7 - ; Endnote must have a library open to display the - after the title name
{
WinActivate
WinGetActiveTitle, title
mytitle:=substr(title, instr(title, "["), -5) ; -5 gets rid of ".enl]"is to end of line
libname:=substr(mytitle, 2) ; basename of library
CompressedFileName = %FullFileName%_%libname% ; get GuiVar variable basefilename and put into variable destination
Send !f ; send alt f to access the File menu
Send {UP 2} ; send 2 up keystrokes to access the compressed file function
Send {ENTER} ; send enter key to choose function
Send {ENTER} ; send the enter key to continue with no changes
sleep 1000
Send %CompressedFileName%
Send {ENTER}
SetTitleMatchMode,1 ; title must begin with String
WinWaitClose, Save Compressed Library
}
else
MsgBox, Please open One Library, No Open Library was found or more than one library is open. Please rectify the situation and rerun the script.