Wednesday, July 1, 2009

An RTF Desktop Wiki, Using AutoHotKey and RoughDraft

This is another version of a desktop wiki, using AutoHotKey. In this incarnation I use the freeware Word Processor Roughdraft, available at Richard Salsbury's Website, as a basis for this script.



Again, the AHK script produces and executes wiki-like links to files in the same directory. Each wiki-page is a separate RTF file, and the script allows for all the Wysywyg features that Roughdraft supports.

This script creates an editor that has wiki-like links to other files in the same directory. Each wiki-page is a separate rtf file. It will thus be preferable to some people over a Plaintext Wiki.

As in the first script, all wiki-files should be placed into their own directory, and two files must be present at all times, which are in the case of this script "Home.rtf" (with the extension) and "garbage.txt". The latter is is used in creating new pages. The links created with this script in this application are not case sensitive.

To create a link, I suggest that you color a word blue, which is easily done in Roughdraft by pressing “^!T” (after you have first set blue in the color selection control). To stop color, you need to press “^!R”. You may also enclose the link in brackets, if you want. But strictly it is not necessary.[1]

Selecting a word and pressing ALT-L will launch the linked page in a new Tab. If there is no linked page, it will create the page and open it in a new Tab. If the page is already open in a Tab, it will just switch to that Tab. AlLT-D will delete both the link and the file, but it will not remove the reference to the file in other wiki-pages. The script cannot automatically rename the files corresponding to the links, but that should be easy to implement.

You can also have a list of all the files in the Wiki Directory (to the right or left of the text, as you wish). Roughdraft usually also displays the drives, but you can force it not to do so by moving the Drive Window all the way to the top.

While the wiki-capabilities are very rudimentary at this point, they do provide the basics. There is still a lot to do. I will probably introduce a couple of new features soon, but ...

I have also tested the script with other rich text editors, and the results are spotty. Wordpad works, Jarte (which is based on Wordpad) does not. I have chosen Roughdraft because it is fairly capable, free, and handles color better than some of the other editors I tried.

I should perhaps also point out that I first adapted the script to make it work with other basic text editors, like Notepad. It works, as long as the editors don’t have fancy controls for saving and opening files. (Notetab Pro did not work—at least not easily. But it has some of this capability out of the box). The most important thing was to slow down the pasting of file names by introducing a “Sleep” and the only difference between that script and the present one is that it substitutes “txt” for “rtf”.

I hope someone will find this useful (and perhaps even improve it) Again, I will probably not use it very much, as I am wedded to ConnectedText and don't find rtf capability that important.[2]

1. The script will happily create and launch links from any word. The color (and brackets) are necessary only to identify the words with links.

2. Here is the script:

!l::
clipboard =
Send ^c
ClipWait
clipboard = %clipboard%
StringReplace, clipboard, clipboard,`],, All
Stringreplace, clipboard, clipboard,`[,, All
Stringreplace, clipboard, clipboard,`.,, All
Stringreplace, clipboard, clipboard,`,,, All
Stringreplace, clipboard, clipboard,`;,, All
Gosub, FileSave
Gosub, FileRead
return

!d::
clipboard =
Send ^x
ClipWait
clipboard = %clipboard%
StringReplace, clipboard, clipboard,`],, All
Stringreplace, clipboard, clipboard,`[,, All
Stringreplace, clipboard, clipboard,`.,, All
Stringreplace, clipboard, clipboard,`,,, All
Stringreplace, clipboard, clipboard,`;,, All
Send %clipboard%
Gosub FileDelete
return

FileSave:
Send !Fs
return

FileRead:
IfExist, %clipboard%.rtf
{
Send !Fo
Sleep, 100
Send %clipboard%.rtf{Enter}
}
Else
{
Gosub Copy
}
Return

Copy:
FileCopy, garbage.txt, %clipboard%.rtf
Gosub FileRead
return

FileDelete:
FileDelete, %clipboard%.rtf
return

3 comments:

L. S. Russell Blogger Beta said...

#IfWinActive ahk_class tednpad
!l::
Send ^c
cb = %clipboard%
StringReplace, cb, cb,`],, All
StringReplace, cb, cb,`[,, All
StringReplace, cb, cb, %A_SPACE%, _, All
Gosub, SFile
Gosub, RFile
return

!d::

return
#IfWinActive

SFile:
Send ^s
return

RFile:
SetWorkingDir , %A_MyDocuments%
IfExist, %cb%.txt
{
Send ^o
Sleep, 100
Send %cb%.txt{Enter}
}
Else
{
Gosub FCopy
}
Return

FCopy:
SetWorkingDir , %A_MyDocuments%
FileAppend , , %cb%.txt
Send ^o
WinWaitActive, ahk_class #32770
Send %cb%.txt{Enter}
return

FileDelete:
SetWorkingDir , %A_MyDocuments%
FileDelete, %cb%.txt
return

Fixed some problems. Used Ted Notepad during test class can be changed, rtc.

MK said...

Thanks a lot.

I still like to have the script in the same directory as the files, which therefore does not have to be set, and it isn't "My Documents." But I see why some might like this.

I like the FileAppend. But I don't think that works for rtf files, or does it?

L. S. Russell Blogger Beta said...

FileAppend didn't work for rtf files. But I didn't have a copy of RoughDraft installed so I went with a regular old notepad.

I really like the idea you have here. I think I'm gonna goof around with it.