AutoHotkey Community

It is currently May 27th, 2012, 12:40 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: December 18th, 2009, 8:50 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
No GetIE(Name="") was designed to get a WebBrowser object based on the IE tab name. If you want to get a WebBrowser object by URL, I would use something like this:
Code:
IEGetURL( URL )
{
   oShell := COM_CreateObject("Shell.Application") ; Contains reference to all explorer windows
   Loop, % COM_Invoke(oShell, "Windows.Count") {   
      If pwb := COM_Invoke(oShell, "Windows.item[" A_Index - 1 "]")
         If InStr( COM_Invoke(pwb, "FullName"), "iexplore.exe" ) ; make sure it's IE
            If InStr( COM_Invoke(pwb, "document.URL"), URL ) ; test if "URL" is in the WebBrowser url
               Break
   COM_Release(pwb), pwb:=
   }
   COM_Release(oShell)
   Return, pwb
}

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Ok! Ty.
PostPosted: December 18th, 2009, 9:28 pm 
Offline

Joined: October 27th, 2009, 2:59 pm
Posts: 25
Maybe I misunderstand you, but can i use your script to identify open URL in IE tab and then select focus in that tab?
if I want to focus InputBox in open Google Tab, should something like this work?

Code:
^f::
URL=www.google.se
pwb := IEGetURL( URL )
com_invoke(pwb,"document.all[q].focus")
return

IEGetURL( URL )
{
   oShell := COM_CreateObject("Shell.Application") ; Contains reference to all explorer windows
   Loop, % COM_Invoke(oShell, "Windows.Count") {   
      If pwb := COM_Invoke(oShell, "Windows.item[" A_Index - 1 "]")
         If InStr( COM_Invoke(pwb, "FullName"), "iexplore.exe" ) ; make sure it's IE
            If InStr( COM_Invoke(pwb, "document.URL"), URL ) ; test if "URL" is in the WebBrowser URL
               Break
   COM_Release(pwb), pwb:=
   }
   COM_Release(oShell)
   Return, pwb
}



I'm very thankful for your help.

_________________
Teddan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 10:30 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Here's an example script that will focus on the Search input box on Google.com:
Code:
COM_Init()
pwb := IEGetURL("google")
hwnd := COM_Invoke(pwb, "hwnd") ; get handle of "pwb" window
TabName := COM_Invoke(pwb, "LocationName") ; get "pwb" tab name
iWeb_Activate(TabName, hwnd) ; activates "pwb" window, and then the correct tab
COM_Invoke(pwb, "document.all.q.focus") ; focus on element
COM_Release(pwb), COM_Term()
Return

NOTE - I had to change the iWeb_Activate() funciton definitition to accept another parameter:
Code:
iWeb_Activate(sTitle, HWND)

@tank - I believe this is an error in the iWeb Standard Library.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Great!
PostPosted: December 18th, 2009, 10:48 pm 
Offline

Joined: October 27th, 2009, 2:59 pm
Posts: 25
Great! it worked fine. however i had to disable the "iWeb_Activate" command. i get "Too many paramters passed to function" from both lines you suggested. So the script doesn't activate the tab but it changes focus to the SearchBox in Google tab. Thanks!

Can you suggest any other way to activate the tab?

Maybe I have old iweb file? where can I find most recent?

Thanks again! i'm very appreciative.

_________________
Teddan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 11:04 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
jethrow wrote:
NOTE - I had to change the iWeb_Activate() funciton definitition to accept another parameter
What I meant was I actually had to go into the iWeb.ahk file and change the following line:
Code:
iWeb_Activate(sTitle)
; change this to:
iWeb_Activate(sTitle, HWND)

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 11:48 pm 
Offline

Joined: October 27th, 2009, 2:59 pm
Posts: 25
Just tried to run this java script in Firefox toolbar having http://en.wikipedia.org open:
Code:
javascript: document.all.searchInput.focus()

shouldn't it work to focus SearchBar here as well. It works great in IE.

Any thoughts?

_________________
Teddan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 11:53 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
javascript: document.all.searchInput.focus()
"all" doesn't seem to work with FireFox. Try:
Code:
javascript: document.getElementById('searchInput').focus()

Also, do you realize you're asking a JavaScript question in an AHK forum? :wink:

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 11:56 pm 
Offline

Joined: October 27th, 2009, 2:59 pm
Posts: 25
Ohh didn't realize that!

Sorry, and Thanks for your kind reply.

I'm going to bed now. So long!

_________________
Teddan


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Leef_me, Ohnitiel, XstatyK, Yahoo [Bot] and 15 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