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


------------------------------------------------------------------------------
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