congdantoancau

Bookmark to Desktop

Sep 17th, 2018
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Bookmark to desktop
  2. ; https://autohotkey.com/docs/commands/FileCreateShortcut.htm
  3. ; IniWrite, http://www.google.com, C:\My Shortcut.url, InternetShortcut, URL
  4. #IfWinActive, Chrom
  5.     F1::
  6.     ^d::
  7.     ; directory
  8.         dir = %A_Desktop%
  9.     ; Get title
  10.         WinGetTitle, title, Chrom
  11.         title := StrReplace(title, "- Google Chrome")
  12.         ; name file are not allow special characters
  13.         if (title != "")
  14.         {
  15.             StringReplace, title, title, `", ', All
  16.             StringReplace, title, title, *, •, All
  17.             StringReplace, title, title, :, ÷, All
  18.             StringReplace, title, title, /, ¦, All
  19.             StringReplace, title, title, |, ¦, All
  20.             StringReplace, title, title, ?, ¿, All
  21.             StringReplace, title, title, `n, %A_Space%~%A_Space%, All
  22.         }
  23.     ; Get url
  24.         Send !c
  25.         Sleep 100
  26.         url = %Clipboard%
  27.     ; Join
  28.         path = %dir%\%title%.url
  29.     ; Write to local   
  30.         if (url != "" and title != "")
  31.         {
  32.             IniWrite, %url%, %path%, InternetShortcut, URL
  33.             ToolTip, %path%
  34.             Sleep, 1000
  35.             ToolTip
  36.         }
  37.     return
  38. #IfWinActive
Advertisement
Add Comment
Please, Sign In to add comment