├── zotpick-scannablecite ├── zotpick.zip ├── LICENSE ├── Scrivener-picker.ps1 └── README.md /zotpick-scannablecite: -------------------------------------------------------------------------------- 1 | @start /b powershell -ExecutionPolicy Unrestricted ./Scrivener-picker.ps1 2 | -------------------------------------------------------------------------------- /zotpick.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmomentOfMusic/Zotero_scrivener_picker_windows/HEAD/zotpick.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 AmomentOfMusic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Scrivener-picker.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | ) 4 | 5 | 6 | add-type -AssemblyName microsoft.VisualBasic 7 | import-module $PsScriptRoot\AutoItX.psd1 8 | 9 | #Get handle of active window (Scrivener) 10 | $Activewindow = Get-AU3WinHandle -Title '' 11 | 12 | # Check if Zotero is running. If not, launch the program and wait until BBT plugin is ready 13 | if ((get-process "zotero" -ErrorAction SilentlyContinue) -eq $Null) 14 | { 15 | Start-Process -filepath zotero.exe -WindowStyle Minimized 16 | 17 | $probe = "starting" 18 | 19 | while ($probe -notmatch "ready") 20 | { 21 | start-sleep -Seconds 1 22 | 23 | try 24 | { 25 | $probe = invoke-webrequest 'http://localhost:23119/better-bibtex/cayw?probe=true' -usebasicparsing -userAgent 'USER' 26 | echo $probe.Content 27 | } 28 | 29 | catch 30 | { 31 | echo "waiting" 32 | } 33 | } 34 | } 35 | 36 | else 37 | { 38 | echo "Zotero is running" 39 | } 40 | 41 | 42 | # Activate Zotero to ensure picker comes to the front 43 | [Microsoft.VisualBasic.Interaction]::AppActivate((Get-Process Zotero).ID) 44 | 45 | 46 | # Call CAYW picker 47 | $ref = invoke-webrequest 'http://localhost:23119/better-bibtex/cayw?format=scannable-cite' -usebasicparsing -userAgent 'USER' 48 | 49 | 50 | # Set Scrivener as foreground window 51 | Show-AU3WinActivate($Activewindow) 52 | Wait-AU3WinActive($Activewindow) 53 | 54 | echo $ref 55 | 56 | # Send result to Scrivener window 57 | Send-AU3Key -key $ref -mode 2 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zotero/Scrivener picker 2 | 3 | This allows you to call up a zotero picker from within Scrivener in Windows 10 using a windowspowershell script by leveraging the framework provided by the Better BibTeX zotero plugin. 4 | 5 | ... or in other words, it allows you to input a citation without leaving scrivener or touching a mouse! This will input scannable cite citation codes, using [the type of picker you see in word and libreoffice](http://mossiso.com/wp-content/uploads/2012/04/zotero-new-view-find-citation.png), which can later be scanned by Zotero to create live citations. It takes a bit set-up but is well worth the effort when you are done! 6 | 7 | This script is written in such a way that it should also work with other plaintext editors that give you the option to trigger a script, as it checks for the current active window when launched, but has not been tested. 8 | 9 | ## Prerequisites 10 | This script has been tested on Windows 10(x64), using zotero 5 and 6, and both Scrivener 1 and 3 for Windows. Instructions below are for Scrivener 3 - for Scrivener 1, the instructions are more or less the same except that the options menu is located under tools menu, not file. 11 | 12 | In order to scan the citations, you will also need to already have installed LibreOffice, as well as the LibreOffice Zotero plugin. 13 | 14 | The script runs off of powershell, which comes with all modern Windows machines. This script also requires the Autoit cmdlet functions. This is to get around a Zotero bug in which the picker does not always appear on top when first called - unfortunately none of the in-built powershell commands did the trick. For ease of use, I have included the necessary files in the zipped folder. Just leave the files in the folder, and everything should work fine. If you prefer, however, you can move the 5 autoitx files to a folder entitled "AutoItX" in the directory C:\Program Files (x86)\WindowsPowerShell\Modules\ - this is however, not necessary. 15 | 16 | ## Instructions 17 | 1. Install the [RTF/ODT plugin for zotero](https://zotero-odf-scan.github.io/zotero-odf-scan/) (Note: Make sure to sure to also follow the "additional Steps" instructions). 18 | 19 | 2. Install the [Better BibTeX plugin](https://retorque.re/zotero-better-bibtex/installation/) 20 | 21 | 3. Download the **zotpick.zip file** from this website 22 | 23 | 4. Unzip the folder 24 | 25 | 5. Place this folder somewhere out of the way (a.k.a somewhere you won't accidentally delete it someday). I suggest leaving it in the Scrivener folder located at C:\Program Files\Scrivener3 but it doesn't actually matter, as long as you can find it later. 26 | 27 | 6. In scrivener, navigate to **file > Option**. Under the **General** tab, click *citations* in the side bar. Click on *choose* 28 | 29 | 7. Navigate to wherever you previously placed the folder. This will appear empty at first. Click on the dropdown menu to change file type, to display **.lnk** files. 30 | 31 | 8. Select the file named **zotpick-scannablecite - Shortcut.lnk** and press okay. Exit the Options window. 32 | 33 | 9. Cite away! You should now be able to call the picker by using the keyboard shortcut for bibliogrphy/citation set by Scrivener. If Zotero is not already open, this script will launch the application in a minimized window. The picker will launch once the betterbibtex plugin is fully loaded, which might take a couple of seconds. You can check what the keyboard shortcut preset is by clicking the **Insert** menu and seeing what is listed next to **bibliography/citations.** Search for the source you need by typing in author name or title, as you would using word or libreoffice plugin. You can also add a colon and a number to include the page number. Press enter when you are done. Voilà! 34 | 35 | > *Note: You can change the keyboard shortcut by going to **File > Options > Keyboard**. Search for "citations" and edit the keyboard shortcut as you please. I use CTR+G* 36 | 37 | 10. When ready, compile scrivener into an odt file. Scan using Zotero as detailed in [this video](https://youtu.be/WO116kjtUow?t=357). 38 | 39 | ## Customizing script 40 | 41 | This script is currently set up to output the scannable cite format. In order to change format, open up the scrivener-picker.ps1 file in a text editor (will open in notepad by default). Look for this line: 42 | 43 | `$ref = invoke-expression "curl 'http://localhost:23119/better-bibtex/cayw?format=scannable-cite'"` 44 | 45 | You can edit the section which says "scannable-cite" to any of the formats listed [on the Better BibTeX webpage](https://retorque.re/zotero-better-bibtex/cayw/ 46 | ) 47 | 48 | I have had some issues with formatted-citation (which outputs whatever style you have set as quick-cite in Zotero) not outputting italics (such as in book titles). I suspect this has to do with the encoding that Better BibTeX outputs, but I'm not 100% sure. Other styles that do not require rich text encoding should be fine. If you are able to solve the issue with italics, please let me know! 49 | 50 | ## Issues 51 | 52 | If you having issues with this script, please let me know in the issues tab on this page. I only have basic level programming skills, so I can't promise an instant fix, but I might be able to address some concerns, or at the very least point you in the right direction. 53 | 54 | One common issue is that the link file doesn't work. If you are having trouble with this script, first try deleting the link file. Right click on the bat file and click *create shortcut.* Once created, right click on the link file and go to properties. Next to *run* select from the drop down menu *minimized* and press okay. Set the link file as the bibliography/citation program in Scrivener. 55 | 56 | The other common problem is with faulty installation of the ODF scannable cite plugin. This has been an ongoing problem with the plugin since the update to Zotero 5. First, to check whether or not this is the issue, in Zotero go to *edit>preferences>export*. Check the dropdown menu under "default format" to see if **scannable cite** is one of the available options. If it is not, then follow the instruction in [this forum post to perform a manual installation](https://forums.zotero.org/discussion/57428/scannable-cite-not-showing-up-in-zotero-standalone). 57 | 58 | Finally, Windows might also be blocking the script from running. Try right clicking each file, and clicking properties. Check the box in the bottom of the dialogue box to unblock the file. 59 | 60 | ## Contributions 61 | 62 | Please feel free to contribute to this project if you feel that you can help. 63 | 64 | ## Acknowledgment 65 | Inspired by [Dave Smith Zotpick applescript](https://github.com/davepwsmith/zotpick-applescript) using a modified version of the work by [Glfruit](https://gist.github.com/glfruit) 66 | 67 | Includes the files for the [AutoIt cmdlet function](https://www.autoitconsulting.com/site/scripting/autoit-cmdlets-for-windows-powershell/) 68 | --------------------------------------------------------------------------------