Don't do any hacks with BibDesk. BibDesk allows to do everything with 
AppleScripts quite nicely.  To remove a field, make it empty, i.e. assign an 
empty string value and the filed will be gone. For actual code examples see my 
script collection at http://www.sysecol.ethz.ch/people/afischli/software

Regards,
Andreas

NOTE: I have a new mobile number!

ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND

andreas.fisch...@env.ethz.ch<mailto:andreas.fisch...@env.ethz.ch>
www.sysecol.ethz.ch<http://www.sysecol.ethz.ch>

+41 44 633-6090 phone
+41 44 633-1136 fax
+41 79 595-4050 mobile

             Make it as simple as possible, but distrust it!
________________________________________________________________________






On 23/11/2011, at 16:41 , Di Xiao wrote:

On Wed, Nov 23, 2011 at 5:25 AM, Christiaan Hofman 
<cmhof...@gmail.com<mailto:cmhof...@gmail.com>> wrote:

On Nov 23, 2011, at 3:10, Di Xiao wrote:

I'm writing an applescript to do the following

1) import bibtex from a webpage in safari
2) generate a cite key according to the auto generation rule set in preferences

Below is the part of applescript

tell document 1 of application "BibDesk"
      activate
      set myPub to first item of (import from theBibTeXString)
      set selection to {myPub}
      tell application "System Events" to keystroke "k" using {command down}
end tell

However, I ran into the following problem.  I use keyword groups.  If
BibDesk is already running and one of the keyword groups is selected,
then the the last line won't run because, unless the imported entry
has the same keyword, it won't be selected.  I checked the BibDesk
dictionary in Applescript Editor.  It seems that I can first select
the "library group" right after "activate".  But I cannot figure out
the proper way to do it.  Any help is appreciated.

D.

Using system events to simulate key strokes is something of a hack, you should 
not use that if it's not necessary. In this case you can simply generate and 
set the cite key in applescript.

tell application "BibDesk"
       activate
       set theFormat to cite key format
       tell document 1
               set thePubs to (import from theBibTeXString)
               if count of thePubs > 0 then
                       set myPub to (get first item of thePubs)
                       set theCiteKey to parse format theFormat for "Cite Key" 
from myPub
                       set cite key of myPub to theCiteKey
               end if
       end tell
end tell

Christiaan


Hi Christiaan,

Thanks a lot!  I was wondering if there is a more elegant way to do
the cite key generation.

I have another question.  I have a script saved in BibDesk's script
folder to do some format cleaning after a record is imported, i.e.,
remove some unnecessary field added by the publisher.  Right now what
I'm doing is again to assign a menu shortcut to that script, then call
it using the system events.  Is there a way to call that script from
the current applescript?

Di

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net<mailto:Bibdesk-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/bibdesk-users


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to