This will do it:—
// Title: Debug
// Description: Starts the Debugger
// Author: Jonathan Kew
// Version: 0.1
// Date: 2010-03-18
// Script-Type: standalone
// Context: TeXDocument
// Shortcut: Alt+S, Alt+D
In a plain text editor save the above into where ever your TwScripts are.
Location of TeXWorks Scripts
"Scripts for TeXworks should be created as text files with the extension .js and placed in the scripts subdirectory of your TeXworks resource folder (typically found within your home directory, exact location is platform-dependent).
The first time TeXworks 0.3 is launched, it will create the scriptsfolder if it does not already exist, and install a few example scripts there. If more examples are added in later releases, you will need to remove or rename the scripts folder in order for the new ones to be installed; the program will not modify an existing scripts folder." ScriptingTeXworks
You can open the Scripts folder from the TeXworks editor Menu> Scripts/ Scripting TeXworks / Scripts Folder
(Other configuration files can be accessed from Menu> Help / Settings and Resources )
I reconfigured my Tw install to a directory where I can pull it off for portable use along with MikTeX portable. (If you do that you'll have to set the Tw preferences to tell it where MiKTeX is —)
So under MS Windows my scripts are below where TeWorks.exe is, i.e. /TeXworks/config/scripts
On Windows, yours might be:—
C:\Documents and Settings\Your Name\TeXworks\scripts
Under Linux and Mac that will be in your /home directory.
You can make sub-folders under the script directory, and place scripts in these.
That will build a sub-menu tree on the Tw Menu://Script/ menu. The sub menus will use the text that you place in the Script header under, and the name of folder that you saved your script into.
Created with the Personal Edition of HelpNDoc: Easily create PDF Help documents