Sitemap | EndNote
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 80
Registered: ‎03-15-2012
0 Kudos

Script for updating imported references with custom information using AutoHotKey in Windows

I have continued playing with AutoHotKey to automate EndNote and have come up with this script to automate the changing of fields and copying of others after import.  Feel free to change anything to reflect your own needs:

 

SetTitleMatchMode,1 ; title must begin with String
IfWinExist,EndNote X7 - [aecclib] ; set the library to what ever your library is - mine is aecclib
{
   WinActivate
   Send !t ; send alt t to access the tools menu
   Send {c 2} ; send to c keystrokes to access the change submenu
   Send {ENTER} ; send enter key to choose menu
   Send {c 7} ; send the c key 7x to choose the Custom 8 field
   Send {TAB 2} ; send the tab kay twice to position in change area
   Send {Down 2} ; send down key twice to choose "replace whole field with:"
   Send {TAB} ; to get to text field
   Send aftergrant2012_09 after2014SFURequest after2014Progressreport ; enter text for excludes in custom 8 field
   Send {TAB}
   Send {ENTER 2}
   sleep 5000 ; sleep 5 seconds to allow updating
   Send {Enter}
; finished section 1 - entering excludes into custom 8 field
sleep 1000 ; sleep for 1 second
   Send !t ; send alt t to access the tools menu
   Send {c 2} ; send to c keystrokes to access the change submenu
   Send {ENTER} ; send enter key to choose menu
   Send {r 4} ; send the r key 4x to choose the Reviewed Item field
   Send {TAB 2} ; send the tab kay twice to position in change area
   Send {Down 2} ; send down key twice to choose "replace whole field with:"
   Send {TAB} ; to get to text field
   Send 2014 from pubmed ; enter text in Reviewed Item field
   Send {TAB}
   Send {ENTER 2}
   sleep 5000 ; sleep 5 seconds to allow updating
   Send {Enter}
; finished section 2 - entering origin of pub (pubmed) and date into reviewed Item field
sleep 1000 ; sleep for 1 second
   Send !t ; send alt t to access the tools menu
   Send {c 2} ; send to c keystrokes to access the change submenu
   Send {ENTER} ; send enter key to choose menu
   Send +{TAB} ; access menu one above
   Send {Right} ; move right one tab
   Send {TAB} ; move to from field
   Send {a 4} ; press a 4x to choose accession number
   Send {Tab}
   Send {L} ; choose label field
   Send {TAB}
   Send {Down 2} ; choose replace entire field
   Send {TAB 2} ; two tabs if the former field is chosen
   Send {Down} ; choose to copy field
   Send {TAB} ; to get to next field
   Send {ENTER}
   Send {ENTER}
   sleep 5000 ; sleep 5 seconds to allow updating
   Send {Enter}
; finished section 3 - copying pmid to label (copy accession number field to label field for duplicate checking)
sleep 1000 ; sleep for 1 second
   Send !t ; send alt t to access the tools menu
   Send {c 2} ; send to c keystrokes to access the change submenu
   Send {ENTER} ; send enter key to choose menu
   Send +{TAB} ; access menu one above
   Send {Right} ; move right one tab
   Send {TAB 4} ; go to move/copy selection
   Send {Down} ; ; choose to copy field instead of moving
   Send {TAB 4} ; move from copy field to from field
   Send {r 3} ; press r 3x to choose record number
   Send {Tab} ; move to "to" field
   Send {c 8} ; press c 8x to choose call number field
   Send {TAB} ; move to next field
   Send {Down 2} ; choose replace entire field
   Send {TAB 3} ; three tabs if the former field is chosen
   Send {ENTER 2}
   sleep 1000 ; sleep for 1 second
   Send {Enter}
; finished section 4 - copying record number to call number field in case of record number change
}

 

The down side to this script is that it starts acting as soon as it is invoked if the EndNote window and library are open.  So the best way to use this, I have found, is to import new records - or select and show only those you wish to update, then invoke the script.  This will update all records being shown in the endnote window.

 

I have also attached the script - in case you want to try it out (just change the extension from .txt to .ahk).

 

ALWAYS make a backup before trying anything like this.  I make a backup of my library using the File->Compressed library (.enlx) ... command before any change and at least once a day

Thomas Zucker-Scharff
Systems Analyst
Frequent Contributor
Posts: 80
Registered: ‎03-15-2012
0 Kudos

Re: Script for updating imported references with custom information using AutoHotKey in Windows

[ Edited ]

I have compiled the script and the update script asks for user input for updating the custom 8 field and the reviewed items field (I thought this would be more universally beneficial), it then copies the accession number to the label field (so you can actually use it to search for duplicates) and the record number to the call number field.

 

The backup script backs up the open library with the date and time preceeding the library name (yyyymmdd_hhmm_<libraryname>).  So my library is name aecclib, when I back it up with this script at 11:01 on 10/09/2014, the file name of the backup is 20141009_1101_aecclib.enlx.

 

The compiled versions of tthe backup script and the update script are too large to be attached (382k each). So I put the scripts in a zip file in my dropbox:

 

https://www.dropbox.com/sh/0ct5ey7xplylt99/AAAz-sUkrbnd0yywTZn7_KaTa?dl=0

 

Update: I have found that the backup script is the most useful of the two and t=I use a script that automates the Find Reference Updates function on a daily basis.  The script, if it is running, will be automatically invoked when you right click on references and choose find reference updates.  Be sure to backup your database before using this.  It updates all fields, even though my library is highly customized, I have yet to have a problem.  I am linking to the compiled version of the script, just extract from the zip file.

 

https://www.dropbox.com/s/iz6lp9khg6t1h3q/findrefupdates.zip?dl=0

 

Thomas Zucker-Scharff
Systems Analyst
Frequent Contributor
Posts: 80
Registered: ‎03-15-2012
3 Kudos

Re: Script for updating imported references with custom information using AutoHotKey in Windows

[ Edited ]

I adjusted the script for EndNote 20 and did a little error checking along with user interaction.  Hope this helps.

 

The script is in the zip file - just extract it and run.  This script is an exe file - so windows only.  It is triggered by holding down the Windows key and the b key (win+b).  If you are interested in the AutoHotKey source code, let me know and I can send that as well.

 

UPDATE: 20210421 - I just updated the script to work better on more systems.

Thomas Zucker-Scharff
Systems Analyst