You could likely copy/adapt the script that the Sledgehammer Add-in is using. A quick way to get to the Add-in folder is to use View...Add-ins, then click the link to go to the Add-in folder. In it, there's a SlidesIntoJournal.jsl script that could serve as a base for your needs.