AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[script] TiddlyWikifier: create PrettyLinks from file paths

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Ace_NoOne



Joined: 10 Oct 2005
Posts: 299
Location: Germany

PostPosted: Fri Jun 08, 2007 1:14 pm    Post subject: [script] TiddlyWikifier: create PrettyLinks from file paths Reply with quote

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
Back to top
View user's profile Send private message
drmurdoch



Joined: 10 Nov 2006
Posts: 110

PostPosted: Mon Mar 10, 2008 2:26 am    Post subject: Reply with quote

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%]]
==============+==
Back to top
View user's profile Send private message
drmurdoch



Joined: 10 Nov 2006
Posts: 110

PostPosted: Mon Mar 10, 2008 2:36 am    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message
drmurdoch



Joined: 10 Nov 2006
Posts: 110

PostPosted: Mon Mar 10, 2008 2:48 am    Post subject: edited for bLADE wiki Reply with quote

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.
Back to top
View user's profile Send private message
Ace_NoOne



Joined: 10 Oct 2005
Posts: 299
Location: Germany

PostPosted: Mon Mar 10, 2008 8:33 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
drmurdoch



Joined: 10 Nov 2006
Posts: 110

PostPosted: Mon Mar 10, 2008 9:41 pm    Post subject: Reply with quote

Yep, works great.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group