AutoHotkey Community

It is currently May 27th, 2012, 1:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Google Chrome Handler
PostPosted: April 14th, 2009, 11:30 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
a simple demo to show how to get gchrome data like webpage title and address. feel free to modify and use under the terms of the license.

Code:
settitlematchmode, 2
g_chrome_wintitle:="Google Chrome"

; ===begin===
gchrome_addr(text){
  global g_chrome_wintitle
  sendmessage,0xC,,% "" text "",Chrome_AutocompleteEditView1,%g_chrome_wintitle%
  if errorlevel=1
    return 0
}

gchrome_go(text){
  critical
  global g_chrome_wintitle
  a:=gchrome_addr(text)
  if a!=0
    return
  else
    sendmessage,0x100,0xD,0x1C0001,Chrome_AutocompleteEditView1,%g_chrome_wintitle%
    sleep 1
}

gchrome_getaddr(){
  global g_chrome_wintitle
  controlgettext,addr,Chrome_AutocompleteEditView1,%g_chrome_wintitle%
  if errorlevel=0
    return addr
  else
    return
}

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_close(){
  global g_chrome_wintitle
  setcontroldelay,100
  setkeydelay,20,10
  controlsend,Chrome_RenderWidgetHostHWND1,{ctrl down}w{ctrl up},%g_chrome_wintitle%
  if errorlevel=1
    return
}

gchrome_newtab(){
  global g_chrome_wintitle
  setcontroldelay,100
  setkeydelay,20,10
  controlsend,Chrome_RenderWidgetHostHWND1,{ctrl down}t{ctrl up},%g_chrome_wintitle%
  if errorlevel=1
    return
}
; ===end===

; examples
F1::tooltip,% "title: " gchrome_gettitle() "`naddress bar: " gchrome_getaddr()
F2::gchrome_go("www.google.com")
F3::gchrome_newtab()
esc::gchrome_close()


notes: yes, the controlsend is silly but works in a very simple way :]
postmessage seems to fail because weird wm_char behavior
oh btw tested only with Google Chrome 2

[ keywords ]
gchrome, chrome, google chrome, chromium, browser, url, address

_________________
                                  [ profile | ahk.net | ahk.talk ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2010, 9:38 pm 
Offline

Joined: December 15th, 2010, 9:06 pm
Posts: 1
Thanks for sharing this code.
I really love how I can now control Chrome with AHK. Chrome is different from regular programs like Notepad. I don't really understand what it is, but your code makes everything fly, whereas I was first faced with a myriad of problems.

NB. Tested w/ Chrome 8 and 10.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2011, 10:56 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
Quote:
Hi.

I noticed that the code stopped working. Do you perhaps have an updated version of your previous script?

Ref post: http://www.autohotkey.com/forum/topic43203.html
Chrome: 14.0.835.xxx. (Sep, 2011)

Thanks!
xBurger


Find and replace "Chrome_AutocompleteEditView1" to "Chrome_OmniboxView1"

_________________
                                  [ profile | ahk.net | ahk.talk ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2011, 9:18 pm 
Offline

Joined: October 4th, 2011, 7:49 pm
Posts: 3
Location: Argentina
Thanks! It's really useful!
Can I ask, how or where did you find the Chrome messages? There is some documentation somewhere?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 6:28 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
oh sorry, didn't see your reply!

yes, I've been way too long without accessing this forum.

you can get these information using some window spy like this one:
http://www.autohotkey.com/forum/viewtopic.php?p=54705

use it to explore the controls and get their proper id.

good luck, anything visit us at irc!

_________________
                                  [ profile | ahk.net | ahk.talk ]


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon and 14 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