click here for a plain text version
#cs
    Clipboard As Name        v0.4

    A "powertoy" for XP, Vista, Windows 7, Windows 8, Server 2003, 2008, 2012, etc..

    Those lovely powertoys won't install in Vista or later versions of Windows,
    so if you are anything like me, you will miss dragging stuff onto your
    "Clipboard As Name" SendTo icon (which you copied to your desktop because it
    was sooo handy, right?), something I did about a zillion times a day in XP.

    What started out as almost a joke (one single line of code) has actually
    transformed into a fairly robust and useful item. After a couple of zillion
    successful drag and drop operations (no really, sometimes it's ten zillion
    a day!) I feel comfortable recommending it, or a shortcut to it, for *your*
    desktop.

    What is it? Too young to remember the Windows PowerToys, huh? Simply put,
    you drag stuff onto it, and the path to that stuff is placed into the
    system clipboard. If you ever need to type the path to a file or folder,
    or many files and folders, ClipbardAsName is what you are looking for.

    So here it is, my favourite Windows PowerToy, AutoIt style..

    ;o)
#ce

#include <WinNet.au3>

; coding doesn't get any easier than this!
; the original ClipbardAsName..
;if $CmdLine[0] then ClipPut($CmdLine[1])
; and there's your application!


; A slightly improved version..
;
; This version handles multiple dropped files.
; Also, holding down the Ctrl key gets you the 8.3 name, just like the original MS PowerToy.
; As a bonus, hold the Shift key to get the REAL network path of mapped resources. Handy.

global $Ctrl = false
global $Shift = false
if _IsPressed(11) then $Ctrl = true
if _IsPressed(10) then $Shift = true


if $CmdLine[0] then
    global $copy = ""
    for $i = 1 to $CmdLine[0]
        global $path = $CmdLine[$i]
        if $Ctrl then $path = FileGetShortName($path)
        if $Shift then
            local $UNC_Array = _WinNet_GetUniversalName($path)
            $path = $UNC_Array[1] & $UNC_Array[2]
        endif
        if StringRight($path, 1) = '"' then
            $path = StringTrimRight($path, 1)
            $path = StringTrimLeft($path, 1)
        endif
        $copy &= $path & @CRLF
    next
    ClipPut(StringStripWS($copy, 3))
else
    MsgBox(0, "
'Clipboard As Name', from corz.org  ",    "To use: Drag and drop stuff onto me, or a shortcut to me. " & @LF & @LF & _
                                    "
The path information will be placed in your system clipboard," & @LF & _
                                    "
so you can immediately paste it wherever you need it (Ctrl+V). " & @LF & @LF & _
                                    "
Okay, technically, you could also launch me with paths on the " & @LF & _
                                    "
command-line, but to save typing, you would first need to get " & @LF & _
                                    "
those paths into your clipboard, which is of course, my job! " & @LF & @LF & _
                                    "
Hold down the Ctrl key while you drag & drop for the 'short' path. " & @LF & _
                                    "
Hold down the Shift key for REAL network path of a mapped resource.")
endif


; _IsPressed (is a key pressed?)
; Author(s): ezzetabi / Jon / Valik
;
func _IsPressed($Key)
    local $kp = DllCall('user32.dll', "
int", "GetAsyncKeyState", "int", '0x' & $Key; does this work on Win9x ? :/
    if not @error and BitAND($kp[0], 0x8000) = 0x8000 then return 1                        ; who cares! ;o)
    return 0
endfunc


#cs
    changes..

    0.4     Added <SHIFT> to get /real/ UNC paths option.

    0.3.2   Added a usage message for if folk click directly on the exe.

            Added a 256 pixel icon for Vista desktop usage, so you can sit it next to your trash, and it will
            scale all the way up with it (Ctrl+Wheel). Those are the only two icons on my desktop. Looks neat.

            I simplified the icon, removing the pencil. I think it works better on your desktop like this, though
            doesn't look quite so impressive on a web page. The former I have to look at almost every day!

    0.3.1   Fixed Vista problem with paths occasionally losing their last character. (I don't have Vista yet!)

    0.3     Added Ctrl key option (8.3 "
short" paths)

    0.2     Added multiple files capability

    0.1     One line of code. cool!
#ce"
back to the source menu
downloadtest

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!