Jump to content

Copy a file to clipboard to be manually pasted as shortcut


Recommended Posts

you can't do that. it needs to live somewhere, the file that is being shortcut-ted to. a shortcut is a .LNK file that contains the information where the app or file it points to lives. You can create lnk files but that actual app or file needs to live on a drive somewhere. what you want is not possible.

in short, there is NO pasting as shortcut. period.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

The file exists. I want to copy it to clipboard using AutoIt and THEN be able to MANUALLY "paste as clipboard" using Windows Explorer (or any File Manager). If you copy a file using Explorer after that you have 2 options: "Paste" and "Paste as shortcut". If you copy a file using AutoIt's _ClipPutFile after that you have only one option: "Paste". So in the end I want to simulate the Explorer's "Copy" command.

@Earthshine I just want be sure I'm making it clear. So can you please confirm your previous reply?

 

Edited by masvil
Link to comment
Share on other sites

Oh, I thought you meant pasting as shortcut from the clipboard. I don't think copying the file to clipboard what you want to do as it only yields the one result. You can create lnk shortcut files in AutoIt for sure. And since you know the file exists and where it lives, this should not be a lot of problems. Explorer is just creating the .lnk file for you with paste as shortcut. Again, I am sure you can do this programatically with AutoIt. update, found it!

FileCreateShortcut

here is the sample from that page. 

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the shortcut filepath.
    Local Const $sFilePath = @DesktopDir & "\FileCreateShortcutExample.lnk"

    ; Create a shortcut on the desktop to explorer.exe and set the hotkey combination Ctrl+Alt+T or in AutoIt ^!t to the shortcut.
    FileCreateShortcut(@WindowsDir & "\explorer.exe", $sFilePath, @WindowsDir, "/e,c:\", _
            "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "15", @SW_SHOWMAXIMIZED)

    ; Retrieve details about the shortcut.
    Local $aDetails = FileGetShortcut($sFilePath)
    If Not @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Path: " & $aDetails[0] & @CRLF & _
                "Working directory: " & $aDetails[1] & @CRLF & _
                "Arguments: " & $aDetails[2] & @CRLF & _
                "Description: " & $aDetails[3] & @CRLF & _
                "Icon filename: " & $aDetails[4] & @CRLF & _
                "Icon index: " & $aDetails[5] & @CRLF & _
                "Shortcut state: " & $aDetails[6] & @CRLF)
    EndIf

    ; Delete the shortcut.
    FileDelete($sFilePath)
EndFunc   ;==>Example

so, since you know where it is, and that it exists, you can just adapt that to your needs as a test mule.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

OK, you put me in the right direction. Thank you!

So for now my best solution is to create the shortcut and then copy the shortcut itself to clipboard, so on the next manual Explorer's "Paste" command the trick is done.
 

#include <Misc.au3>

$FileCreateShortcut = FileCreateShortcut("path\to\file", @TempDir & "\shortcut.lnk", @ScriptDir, "", "", "", "")

_ClipPutFile(@TempDir & "\shortcut.lnk")

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...