NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Randy Williams on 2010-10-03 01:45 am

Title: Script to print to PDF
Post by: Randy Williams on 2010-10-03 01:45 am
I doubt anyone will have a need for this script, as I did, but thought I'd post it anyway.  Apologies in advance if wasting your time.  And if someone has a similar script done with "AutoIt" instead of VBScript, I'd be interested in it.

Attached script automates key sequences needed to print current song in NWC to PDF file (song need not be saved to a file).  Script was written to expect PDFCreator 0.9.6, but I believe it can easily be modified for other PDF printers if needed.  Script allows for an optional command-line option which becomes a differentiating suffix for the PDF file.

Script does "inject" key presses, which I'm not a big fan of, but it has some safeguards.  It only does key presses, and never does mouse clicks.  It makes every attempt to ensure correct application has focus before injecting key presses.  It does nothing to the NWC session (or the original file), but instead spawns a separate NWC Viewer (via a temporary file) to do the printing (script can be greatly simplified if one is comfortable injecting to NWC itself - I was not).

I use this script in conjunction with "Run User Tool", so that a single user tool invocation can sequence some automated conversions and then print the result to a PDF, followed by a revert and running another similar user tool to create and print an alternate version, and so on.  Each top-level user tool automatically does everything needed to create and print its specific version.

Invocation command for general use is: wscript scripts\prw_PrintToPdf.vbs "<PROMPT:Suffix:=*>"

Drop ".txt" from file name after downloading.  Specify "File Text" for "Input Type".  Specify "Long Task Handling" option.
Title: Re: Script to print to PDF
Post by: Flurmy on 2010-10-04 07:41 am
Sorry, I must be sleepy. What's the use of such a program?
Isn't easier (or virtually the same) to use "file->print->PDFCreator" as I do so often?
Title: Re: Script to print to PDF
Post by: Randy Williams on 2010-10-04 04:58 pm
What is the idea of any script, but to automate a process which would be tedious to manually do otherwise?!

I found myself doing the following 5 separate times for every hymn I entered:

If you find that doing this process so often is easier (or virtually the same) than running a single user tool, you're perfectly welcome to do so!  I have no illusions that this script is a great time-saver for everyone - it just works well for me, and I thought I'd share it, just in case.  Again, apologies if I'm further wasting anyone's time here.

[Using RunUserTool and other scripts, I am fast getting to the point where a single user tool invocation can automatically generate all 5 of my PDFs for a hymn (for C instrument, Bb instrument, F instrument, Eb instrument, and C instrument alto clef).  This PrintToPDF script was a part of that automation process.]
Title: Re: Script to print to PDF
Post by: Flurmy on 2010-10-05 07:40 am
Quote
I am fast getting to the point where a single user tool invocation can automatically generate all 5 of my PDFs for a hymn (for C instrument, Bb instrument, F instrument, Eb instrument, and C instrument alto clef).  This PrintToPDF script was a part of that automation process.

Aha, this makes a lot more sense!

Quote
Again, apologies if I'm further wasting anyone's time here.

Oh, I think I'll survive... ;-)
Out of joke: mine was not a critic, I was simply curious.