Rip the URL from the Clipboard with AutoHotkey

Someone asked me if I had a tool that would look at the clipboard and return only the URL or Rip the  URL from the Clipboard. (The clipboard has various formats like: Files, Text, Rich Text Format, HTML, Images, etc.).

I used the cool WinClip library which can be grabbed here: https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/ and, with the help of maestrith, wrote a script which returns the various items on the clipboard in HTML format as an object.

Rip the URL from the Clipboard

 
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
SetBatchLines,-1
global Com:=ComObjCreate(“HTMLFile”)
;*******************************************************
Browser_Back:: ;Change this hotkey to what you want
CB:=ClipboardAll
Clipboard:=””
while(Clipboard){
Sleep,10
}
Send,^c
while(!Clipboard){
Sleep,10
}
Clip:=Get_Clipboard_Data() ;Call the function and return the HTML data in an object
MsgBox % clip.1.HREF
DebugWindow(Obj2String(Clip),1,1,200,0)
Clipboard:=CB ;restore Clipboard
return

;********************Grab data from Clipboard***********************************
Get_Clipboard_Data(){
wc := new WinClip
wc.iSnap()
Obj:=[]
try:=wc.iGetHTML()
HTML:=SubStr(Try,InStr(Try,”<HTML>”))
Com.Close()
Com.Write(HTML)
All:=Com.GetElementsByTagName(“a”)
Url:=[]
RegExMatch(Try,”OUi)SourceURL:(.*)\R”,Found)
while(aa:=All.Item[A_Index-1]){
URL.Push({Page:Found.1,Text:aa.InnerText,HREF:aa.HREF})
}
return URL
}
;~ https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClipAPI.ahk
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClip.ahk

AutoHotkey Webinar- Learn AutoHotkey quickly

In the first hour of the webinar we walked through the process for how to learn anything (including AutoHotkey) quickly

Hour 1: High-level overview
Hour 2: Q&A

Script Highlight:  Merging / Appending files of similar structure

  • A-Z Database allows for extracting contacts up to 1,000 at a time. Check your local library for access
  • For simplification I extracted 25 at a time, then merge together.
  • Each csv file has a header row
  • Every file has the same headers
  • Get the source code here

Learn AutoHotkey quickly

Continue reading

Merging Files with similar structure but removing duplicate headers

I often get text files of similar type (Tab delimited, CSV, etc.) but they all have a header row.  A super easy way to merge the data together is to

  1. Created a folder that only has the files you want to merge
  2. create a command prompt in the directory
  3. use the following dos command to merge the files (adjusting the extension to your purpose:  copy *.csv  merged.csv

This will merge all of the files ending in .csv into the merged.csv file however it keeps all the header rows. 🙁   This annoyed me so I wrote a short program to use AutoHotkey and only keep the first header row. Continue reading