congdantoancau

Download url | Save url

Jun 12th, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Chrome extension resources
  2. ; * Link url (ctrl+c): https://chrome.google.com/webstore/detail/copy-link-address/kdejdkdjdoabfihpcjmgjebcpfbhepmh
  3. ; * Link text (alt+shift+c): https://chrome.google.com/webstore/detail/copy-link/mjpbijfgaajfmabmfnabchojdlpfnbbi
  4.  
  5. ; * Copy current url (alt+x): https://chrome.google.com/webstore/detail/copy-url/mkhnbhdofgaendegcgbmndipmijhbili
  6. ; * Copy url (alt+c): https://chrome.google.com/webstore/detail/copy-2-clipboard-with-eas/hiiobhaaokpmdmkkcaokdlanlemmcoah
  7. ; * Copy URL (alt+c): https://chrome.google.com/webstore/detail/copy-url/cmimjipjncmkldkeffkiebkijekcjnjd
  8. #IfWinActive, Chrom
  9.     F1::
  10.     ^d::
  11.         title := "unknown" ; default title
  12.         url := "http://www.example.com" ; default url
  13.         ; https://autohotkey.com/board/topic/47789-how-to-check-if-a-directory-exists/
  14.         If( InStr( FileExist("I:\Bookmark"), "D") )
  15.             defdir := "I:\Bookmark" ; default target
  16.         else
  17.             defdir := "D:\"
  18.         Clipboard:= ; clear clipboard
  19.        
  20.         ; Prepare directory path
  21.         ; find current opened folder
  22.         If WinExist("ahk_class CabinetWClass")
  23.             dir := WinGetPath("ahk_class CabinetWClass")
  24.         if InStr(dir, "Search Results")
  25.             dir := defdir
  26.  
  27.         ; CASE 1: HOVER COPY   
  28.        
  29.         ; * prepare url
  30.         send, ^c ; get url
  31.         Sleep, 100
  32.         url := Clipboard
  33.         Clipboard:=
  34.        
  35.         ; * prepare title
  36.         send, !+c ; get title
  37.         Sleep, 200
  38.         title := Clipboard
  39.         Clipboard:=
  40.        
  41.         if (url == "") ; hover link is not exist
  42.         {
  43.             ; CASE 2: COPY CURRENT URL
  44.            
  45.             ; prepare current tab link
  46.             ; * get title
  47.             WinGetTitle, title, A
  48.            
  49.             ; * get url
  50.             If WinActive("Chrome Web Store") or WinActive("Cửa hàng")
  51.             {
  52.                 Send, !d ; Highlight url
  53.                 Sleep, 100
  54.                 Send, ^c ; Copy url
  55.                 dir := "I:\Extensions"
  56.             }
  57.             else ; Other pages
  58.             {
  59.                 Send, !c ; !x ; COPY URL extension shortcut key
  60.             }
  61.             Sleep, 100 ; Wating for clipboard
  62.             url := Clipboard
  63.         }
  64.         else ; hover link is detected
  65.         {
  66.             if (title == "") ; copy title above is unsuccessful
  67.             {
  68.                 ; try to get title
  69.                 send, {shift down}{Rbutton}{shift up}
  70.                 Sleep, 200
  71.                 send, {down}
  72.                 send, c
  73.                 Sleep, 100
  74.                 title := Clipboard
  75.             }
  76.         }
  77.        
  78.        
  79.         ; Title format acceptized
  80.         StringReplace, title, title, ", ', All
  81.         StringReplace, title, title, *, •, All
  82.         StringReplace, title, title, :, ÷, All
  83.         StringReplace, title, title, /, ¦, All
  84.         StringReplace, title, title, |, ¦, All
  85.         StringReplace, title, title, ?, ¿, All
  86.         StringReplace, title, title, `n, %A_Space%~%A_Space%, All
  87.        
  88.         ; Write links to folder
  89.         IniWrite, %url%, %dir%\%title%.url, InternetShortcut, URL
  90.        
  91.         ; Alert
  92.         ToolTipFont("s10", "")
  93.         if (Title != "" && Url != "")
  94.             ToolTipColor("white", "green")
  95.         else if (Title == "")
  96.             ToolTipColor("yellow", "red")
  97.         else if (Url == "")
  98.             ToolTipColor("orange", "red")
  99.  
  100.         ToolTip, ● Saved to %dir% |`n● Title = %title% |`n● Url = %url% |, 20, A_ScreenHeight - 100
  101.         Sleep, 1000
  102.         ToolTip
  103.     return
  104. #IfWinActive
Add Comment
Please, Sign In to add comment