masvil Posted March 22, 2018 Share Posted March 22, 2018 How can I copy a file to clipboard to be manually pasted as shortcut through Explorer? If I use _ClipPutFile then only "Paste" command is available in Explorer context menu. I need "Paste as shortcut" to be available too. Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted March 22, 2018 Share Posted March 22, 2018 (edited) 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 March 22, 2018 by Earthshine masvil 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
masvil Posted March 22, 2018 Author Share Posted March 22, 2018 (edited) 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 March 22, 2018 by masvil Link to comment Share on other sites More sharing options...
Earthshine Posted March 22, 2018 Share Posted March 22, 2018 (edited) 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 March 22, 2018 by Earthshine masvil 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
masvil Posted March 22, 2018 Author Share Posted March 22, 2018 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") Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted March 22, 2018 Share Posted March 22, 2018 (edited) Or just create it where you want it. Be it desktop or in a directory or on the Start Menu Edited March 22, 2018 by Earthshine masvil 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now