Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Basic Webpage Controls with JavaScript / COM - Tutorial


  • Please log in to reply
335 replies to this topic
fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
How would it not be relevant? I'm using this for explorer windows, not for IE windows with tabs and it works fine there mostly.

The IEGet method should work for explorer after some customization, I haven't decided yet which one might work better. Hwnd method might be able to reach windows which incorporate a shell view? I'm not sure yet if that would be a pro or con.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
because the shellwindows collection is in the order created which has nothing to do with which one is active what is wrong with
hwnd:=WinExist("ahk_class CabinetWClass")
which would get the top most file explorer window

there is no need to go thru the complexity of rifleing thru the shellwindows collection at all unless your later planning on using COM in which case you would want the already known via winexist hwnd to be compared with the other hwnd's in the shell collection so you may arrive at a proper pwb
Never lose.
WIN or LEARN.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
That's exactly what I'm doing, sorry if I didn't make that clear.
I'm calling various COM functions like Navigate2, SelectFiles etc on the active explorer window.

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Post deleted - placed in wrong thread.

anomalous3
  • Members
  • 8 posts
  • Last active: Feb 05 2010 10:42 PM
  • Joined: 23 Nov 2009
I noticed in my task manager that "iexplore.exe" stays open and munches up memory even if you use the COM_Invoke(pwb, "Quit") method, so I did some searching on the MSDN and found that I need to use the COM universal "Close" method as well to free up the resources used by the exited internet explorer object like this:
COM_Invoke(pwb, "Close")


anomalous3
  • Members
  • 8 posts
  • Last active: Feb 05 2010 10:42 PM
  • Joined: 23 Nov 2009
I noticed in my task manager that "iexplore.exe" stays open and munches up memory even if you use the COM_Invoke(pwb, "Quit") method, so I did some searching on the MSDN and found that I need to use the COM universal "Close" method as well to free up the resources used by the exited internet explorer object like this:
COM_Invoke(pwb, "Close")


jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
I don't know much about the COM universal "Close" method, but are you using a different pwb (pointer) to close each WebBrowser Object? (pwb1, pwb2, pwb3 ...). Additionally, you could also use Process, Close.

Gundeck
  • Members
  • 5 posts
  • Last active: Feb 04 2010 10:09 PM
  • Joined: 26 Jan 2010
I didn't get past step 1.
I downloaded the OCM.ahk, I didn't see anything to do on the page for Standard Library.

When I copy and paste the scripts and paste it into my address bar, while on the Forum Search page... I get nothing.

I guess I'll hit some of the other listed tut's that are linked on this page.
What am I doing wrong?

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

I downloaded the OCM.ahk, I didn't see anything to do on the page for Standard Library.

Please read this. COM.ahk goes in your "Lib" folder; the path should be something like "C:\Program Files\AutoHotkey\Lib"

When I copy and paste the scripts and paste it into my address bar, while on the Forum Search page... I get nothing.

So, when you are on the Search Forum page and enter the following code into the URL Address bar and hit enter, nothing happens?
javascript: document.[color=red]all[/color].search_keywords.value = 'Input Value'; void(0)
If so, what browser are you using? I have noticed that FireFox doesn't like all, but you could use:
javascript: document.[color=red]getElementsByName[/color]('search_keywords')[0].value = 'Input Value'; void(0)


spoonerelo
  • Guests
  • Last active:
  • Joined: --
Is it possible to control firefox in the same way as internet explorer?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
no
2 different APIs and ahk is blind to firefox
Never lose.
WIN or LEARN.

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Is it possible to control firefox in the same way as internet explorer?

As tank said, no, firefox is not a COM object. You could use javascript injection though, something like this:
ClipBoard := "[color=olive]javascript: document.getElementsByName('search_keywords')[0].value = 'Input Value'; void(0)[/color]"
Send, !d^v{Enter}


Gundeck
  • Members
  • 5 posts
  • Last active: Feb 04 2010 10:09 PM
  • Joined: 26 Jan 2010

I downloaded the OCM.ahk, I didn't see anything to do on the page for Standard Library.

Please read this. COM.ahk goes in your "Lib" folder; the path should be something like "C:\Program Files\AutoHotkey\Lib"

When I copy and paste the scripts and paste it into my address bar, while on the Forum Search page... I get nothing.

So, when you are on the Search Forum page and enter the following code into the URL Address bar and hit enter, nothing happens?
javascript: document.[color=red]all[/color].search_keywords.value = 'Input Value'; void(0)
If so, what browser are you using? I have noticed that FireFox doesn't like all, but you could use:
javascript: document.[color=red]getElementsByName[/color]('search_keywords')[0].value = 'Input Value'; void(0)


Wait a minute... Shoe leather taste better with salt on it... I guess I should open my eyes.
It worked as described. I'm an idiot, sorry :?

randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Can I use this/COM to automate the retreival of a webpage source by URL?

I have a URL to a dynamically built page, I want IE to open the window -in the background- and save the source to a file.

I was looking at this line:
text := COM_Invoke(pwb, "document.getElementsByTagName[TD].item[2].innerHTML")

But I'm not sure how to set up everything that wraps it. I just get an error...

Is there any way I could beg for an example? Thank you!

randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Read some more and did this, but still get an error:

com_init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
text := COM_Invoke(pwb, "document.getElementsByTagName[TD].item[2].innerHTML")
msgbox %text%

'no com dispatch object'... what am I missing?