AutoHotkey Community

It is currently May 27th, 2012, 8:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: December 27th, 2011, 4:42 am 
Offline

Joined: April 19th, 2011, 4:55 am
Posts: 298
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
}


Last edited by Xx7 on January 30th, 2012, 5:25 am, edited 6 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2011, 5:23 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
You might want to make a note (in the title or something) that this is AHK_L only.

It's a cool idea :)

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2011, 1:11 pm 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
would be good if there was a helper script to go with it that would bring up an imput box and you could quickly search your bookmarks and then execute (go to)that web site


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2011, 4:35 pm 
FYI: I noticed you use:

Code:
clipboard =
Sendinput, ^l  ;highlights address bar
Sendinput, ^c  ;copies web address


k3ph Submitted a ChromeHandler which is very good at extracting the URL and Titles.

http://www.autohotkey.com/forum/topic43203.html&highlight=gchromewintitle+google+chrome

Although it looks long and overkill, the actual part one needs, is quite small and tidy.

Moderator's Note: Omitted space after url in [url][/url] tags. ~ sinkfaze


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2011, 8:27 pm 
Offline

Joined: April 19th, 2011, 4:55 am
Posts: 298
Good idea Jung Rae Mun. One way would be to take the input box entry and use it to perform a vlookup in the first 2 Excel columns. A gui would likely be a more user friendly option though.

Thanks LarryC... I updated it with k3ph's code


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2012, 5:01 am 
Offline
User avatar

Joined: September 1st, 2011, 8:21 pm
Posts: 368
Location: California
looks good :), you forgot to list the function Excel_Get()
and I am guessing you are inserting rows at the top because you don't know where the last row is, try the following instead:
Code:
xl.Range("A" xl.Cells.SpecialCells(11).Row +1).Value :=  Hyper1
xl.Range("B" xl.Cells.SpecialCells(11).Row   ).Value :=  Text

or this line for inserting rows at the top
Code:
xl.Rows("1:1").Insert(-4121)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 8th, 2012, 6:50 pm 
Offline

Joined: April 19th, 2011, 4:55 am
Posts: 298
marktuffy wrote:
Well, it is very strange information as to store Google chrome into excel sheet. I am very much curious to know more on this.


It allows me to create a searchable database to retrieve bookmarks by using advancedfilters and macros in Excel. Therefore, I can have 1000's of bookmarks and search them instantenously with a key word or a string which will filter them to the top of a list. Its also more accessible as you can transfer your excel file between computers easily.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group