Monday, December 30, 2013

A Markdown Wiki with Texts and Autohotkey

Here is what works with Texts on my computer:

#SingleInstance force

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

clipboard =
send, {esc}{Home}+{End}
Sleep 200
Send, ^c
Send, ^s
sleep, 200

clipboard = %clipboard%
linestring := clipboard
bit1 = [[ ;find the position of the character "[", call it leftmark
StringGetPos, leftmark, linestring, %bit1%
leftmark := leftmark + 3

bit2 = ]] ;find the position of the character "]", call it rightmark
StringGetPos, rightmark, linestring, %bit2%
rightmark := rightmark + 1

stringlength := rightmark - leftmark
thefilename := SubStr(linestring, leftmark , stringlength)".text"
topicname := SubStr(linestring, leftmark , stringlength)

IfExist, %thefilename%
    Send ^o 
    Sleep 400
    Send %thefilename%{Enter}
    sleep 100
    Send, ^{End}
IfNotExist, %thefilename%
    FileAppend, `#`#`# %topicname%, %thefilename%
    Send ^o 
    Send %thefilename%{Enter}
    sleep 100
    Send ^{End}

This little script "implements" only very basic functions of a personal wiki.

No comments: