congdantoancau

Send to desktop hotkey

May 18th, 2018
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Begin Send to desktop
  2. ^+d::
  3. ; Get file name
  4. file_path := % gst()
  5. if (file_path == "") ; if there is no file is selected
  6. {
  7.     return
  8. }
  9. StringSplit, array, file_path, \
  10. file_name := array%array0%  ;Contains the value of the last item in Array. Use ":=" for assignation.
  11. ; Remove extension
  12. StringSplit, array, file_name, .
  13. file_name := array1
  14.  
  15. ; Create shortcut
  16. FileCreateShortcut, % file_path , %A_Desktop%\%file_name%.lnk
  17. return
  18.  
  19. ; Resources
  20. ; https://autohotkey.com/docs/commands/FileCreateShortcut.htm
  21. ; GetSelectedText or FilePath in Windows Explorer  by Learning one
  22. ; https://autohotkey.com/board/topic/60723-can-autohotkey-retrieve-file-path-of-the-selected-file/
  23. gst() {  
  24.     IsClipEmpty := (Clipboard = "") ? 1 : 0
  25.     if !IsClipEmpty {
  26.         ClipboardBackup := ClipboardAll
  27.         While !(Clipboard = "") {
  28.             Clipboard =
  29.             Sleep, 10
  30.         }
  31.     }
  32.     Send, ^c
  33.     ClipWait, 0.1
  34.     ToReturn := Clipboard, Clipboard := ClipboardBackup
  35.     if !IsClipEmpty
  36.     ClipWait, 0.5, 1
  37.     Return ToReturn
  38. }
  39. ; End Send to desktop
Advertisement
Add Comment
Please, Sign In to add comment