When a Google Chrome webpage is active press Ctrl+Alt+B and it will store the hyperlink and page title in an Excel file with the most recent at the top.
Any improvements/tips appreciated!!!... especially in the COM area
EDIT: Thanks LarryC... updated with
k3ph's code
UPDATED: Jan 29/12
Code:
#SingleInstance Force
#IfWinActive ahk_class Chrome_WidgetWin_0
settitlematchmode, 2
g_chrome_wintitle:="Google Chrome"
^!b::
FullFileName = C:\Users\BD\Desktop\Bookmarks.xlsx ;Excel file to store Bookmarks
SplitPath, FullFileName,,,, Name_no_ext ;Retrieves file name without ext
text = % gchrome_gettitle() ;gets webpage title
html = % gchrome_getaddr() ;gets web address
htmlHTTP := "http://" html ;web address with "http://" at beginning
Hyper1 = =hyperlink("%htmlHTTP%","%html%") ;formula for Excel hyperlink cell
;----------------------------------------------
if BookExist("Bookmarks") ;if bookmarks open.. activate
WinActivate, Microsoft Excel - %Name_no_ext%
else ;else open it in new instance
{
Run, Excel.exe "%FullFileName%"
WinWait, Microsoft Excel - %Name_no_ext%
WinActivate, Microsoft Excel - %Name_no_ext%
}
;----------------------------------------------
Sleep, 100
XL := Excel_Get() ; access the Excel object
;-----Inserts a row at the top of the Excel file-----
XL.Range("A1").Select ; select A1 cell
SendInput, {shift down}{space}{shift up} ;select row A
SendInput, {ctrl down}{shift down}={shift up}{ctrl up} ;insert row ^+{plus sign}
Sleep, 100
;-----Enters the hyperlink and webpage text-----
XL.Range("A1").Value := Hyper1
XL.Range("B1").Value := text
XL.ActiveWorkbook.Save
XL.Quit
return
;#############################################
;-----Thanks to k3ph--------------------------
;http://www.autohotkey.com/forum/topic43203.html
;Copyright license: http://www.autohotkey.net/~k3ph/license.txt
gchrome_gettitle(){
global g_chrome_wintitle
wingettitle,gchrome_title,%g_chrome_wintitle%
stringreplace,gchrome_title,gchrome_title,% "- " g_chrome_wintitle
if errorlevel=0
return gchrome_title
else
return
}
gchrome_getaddr(){
global g_chrome_wintitle
controlgettext,addr,Chrome_OmniboxView1,%g_chrome_wintitle%
if errorlevel=0
return addr
else
return
}
;#############################################
;-----Thanks to Alpha Bravo--------------------------
;http://www.autohotkey.com/forum/viewtopic.php?t=81871&sid=b56acd8f84008f4b820d599219ba6bfc
BookExist(_BookName)
{
IfWinExist, Microsoft Excel -
For Book in ComObjActive("Excel.Application").Workbooks
If InStr(Book.name,_BookName)
return, 1
}