AutoHotkey Community

It is currently May 26th, 2012, 6:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: June 8th, 2007, 2:14 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
Hey all,

Here's a small script to convert file paths to TiddlyWiki links.
It has been requested (sort of) on the TiddlyWiki mailing list.

The script is meant to be called via the SendTo context menu, but it can also be run manually with parameters; the first parameter is the file path, the second parameter is an optional link title.

The code has not been extensively tested, and you will have to manually create the SendTo shortcut (also see MSKB) - but it should do the job.
Also, be aware that this will overwrite the clipboard contents! (I couldn't be bothered coming up with a satisfying solution for that... )

I've uploaded the source code as well as the compiled EXE.

Here's the source code again:
Code:
/*
TiddlyWikifier v1.0
 by FND

Converts Windows file paths to TiddlyWiki PrettyLinks
*/

/*
ToDo:
- backup clipboard
- automatically add a shortcut to the SendTo menu
*/

/*
Changelog
¯¯¯¯¯¯¯¯¯
# v1.0 (2007-06-08)
* initial release
*/

/*
********** Settings, Variable Declarations **********
*/

#SingleInstance Force
#NoEnv
OnExit, quit

programName = TiddlyWikifier
programVersion = 1.0
programFullName = %programName% v%programVersion%
programAuthor = FND

filePath =
title =

/*
********** Auto-Execute Section **********
*/

; backup clipboard contents
;clipboardBak := ClipboardAll ; DEBUG: disabled, as it complicates script termination
; process command line parameters
GoSub, getParams
; get title (optional)
If(title = "")
{
   InputBox, title, %programFullName%, Please enter a title for your link.`n(Press cancel to not use a custom title.)
      ,,,,,,,, %filePath%
   If(ErrorLevel = 1)
      title =
}
; convert file path
StringReplace, filePath, filePath, \, /, All ; convert slashes to Unix format
filePath = file:///%filePath% ; add file protocol
; construct PrettyLink
If(title = "")
   tiddlyLink = [[%filePath%]]
Else
   tiddlyLink = [[%title%|%filePath%]]
; copy PrettyLink to clipboard
Clipboard := tiddlyLink
; end of auto-execute section
Return

/*
********** Subroutines **********
*/

; process command line parameters
getParams:
   If 0 > 0
   {
      filePath = %1%
      if(title != "")
         title = %2%
   }
Return

; terminate script
quit:
   ; restore clipboard contents
   ;Clipboard := clipboardBak ; DEBUG: disabled; see above
   ; terminate script
   ExitApp
Return

_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2008, 3:26 am 
Offline

Joined: November 10th, 2006, 5:10 am
Posts: 110
I can't seem to add the shortcut to the .ahk script in the Windows Send To.
should I reboot ?

====for bLADE wiki ===
Else
tiddlyLink = [[%title%][%filePath%]]
==============+==


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2008, 3:36 am 
Offline

Joined: November 10th, 2006, 5:10 am
Posts: 110
I compiled it .. and put a shortcut to the .exe file.
and now it shows up in the Send To Menu.
... but its not working ..
or it is but super slow ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: edited for bLADE wiki
PostPosted: March 10th, 2008, 3:48 am 
Offline

Joined: November 10th, 2006, 5:10 am
Posts: 110
Code:
If(title = "")
   tiddlyLink = [%filePath%]
Else
   tiddlyLink = [[%filePath%][%title%]]
; copy PrettyLink to clipboard


Great script. Thank you.
FYI, I believe you have to compile the script for it to work in the Send To Menu.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2008, 9:33 am 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
So it worked after all?
It's been a while since I've used this (I'm on Linux now), so I'm having a hard time remembering how it worked.

_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2008, 10:41 pm 
Offline

Joined: November 10th, 2006, 5:10 am
Posts: 110
Yep, works great.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], mrhobbeys, nothing, siterip, Stigg and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group