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
UncleScrooge
  • Members
  • 75 posts
  • Last active: Sep 22 2010 09:12 PM
  • Joined: 14 Apr 2009

:shock: - Why are you using pweb & pwb? Should be:

MsgBox % COM_Invoke([color=red]pweb[/color],"document.getElementsByTagName[h1].item[0].innerHTML")


holymoly! what a moron... (me)
that's it! just a stupid "e" bug (friggin Napier)

thx a ton jethrow and all of you guys.
Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3

poetbox
  • Members
  • 113 posts
  • Last active: Sep 11 2013 08:05 AM
  • Joined: 07 Jan 2007
I use the COM_U to deal with a Unicode file,an error occar.
Posted Image
What shall I do?[/img]

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
In a function variables do not require percent signs unless you are using them dynamically (and literal text must be quoted):

COM_Invoke(pweb,"document.all.atc_content.value",[color=red]A_LoopField[/color])


poetbox
  • Members
  • 113 posts
  • Last active: Sep 11 2013 08:05 AM
  • Joined: 07 Jan 2007

In a function variables do not require percent signs unless you are using them dynamically (and literal text must be quoted):

COM_Invoke(pweb,"document.all.atc_content.value",[color=red]A_LoopField[/color])

Thank you.Very good.
OK!

incith
  • Members
  • 130 posts
  • Last active: Apr 03 2010 03:08 AM
  • Joined: 01 Oct 2005
Having a problem with an onchange + onkeyup event. Basically I am trying to put text into a field, which is working fine, and then clicking the Search button, which also works fine.

The problem comes with the field I am putting text into, is expecting you to be typing into the field. When you type into the field it then triggers the onchange / onkeyup events:
<INPUT onkeyup=fullNameParse267656572(this.value) onchange=fullNameParse267656572(this.value) value="THE TEXT I PUT IN" name="attribute.Full Name" autocomplete="off">
Using
iWeb_setDomObj(netcare,"attribute.Full Name",myName,"23,48,10")
to set the text within an iFrame, but it does not trigger the events. I tried playing with iWeb_FireEvents() to no luck.

Offtopic Edit: The "ahk web recorder" program is freaking wonderful. The only bug that threw me off at first was that it does not comma separate the first two iFrame numbers, e.g. I had iFrame one number "23" and the second was "48", and a third was "10". It gave me "2348,10". Once I changed it to "23,48,10" all worked great.

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
Try firing the onchange event like this:
element := COM_Invoke(netcare, "document.all[23].contentWindow.document.all[48].contentWindow.document.all[10].contentWindow.document.all","attribute.Full Name")
COM_Invoke(element, "fireEvent", "onchange")
btw - MERRY CHRISTMAS

incith
  • Members
  • 130 posts
  • Last active: Apr 03 2010 03:08 AM
  • Joined: 01 Oct 2005

Try firing the onchange event like this:

element := COM_Invoke(netcare, "document.all[23].contentWindow.document.all[48].contentWindow.document.all[10].contentWindow.document.all","attribute.Full Name")
COM_Invoke(element, "fireEvent", "onchange")
btw - MERRY CHRISTMAS


Thank you VERY MUCH!

This is the present I needed most. :)

Seasons Greetings to all!!!!

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008

Offtopic Edit: The "ahk web recorder" program is freaking wonderful. The only bug that threw me off at first was that it does not comma separate the first two iFrame numbers...


A problem none of us who are working on it probably had a chance to catch because we don't have any web pages that required us to recurse that deep into frames readily available to us. The official release probably won't be updated for a week or more, in the meantime you can make this change in the script under the Ctrl+e hotkey (should be around line 181):

fpath.=(A_Index=1 ? "" : ",") ((f1) ? (f1) : ((f3) ? (f3) : (f2))) ; the ternary statements should've been reversed

And thanks for the compliments. :)

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I'm referring to this piece of code quoted in the first post in tanks thread from Sean:

COM_Init() 
psh :=   COM_CreateObject("Shell.Application") 
psw :=   COM_Invoke(psh, "Windows") 
Loop, %   COM_Invoke(psw, "Count") 
   pwb := COM_Invoke(psw, "Item", A_Index-1), sInfo .= COM_Invoke(pwb, "hWnd") . " : """ . COM_Invoke(pwb, "LocationURL") . """,""" . COM_Invoke(pwb, "LocationName") . """,""" . COM_Invoke(pwb, "StatusText") . """,""" . COM_Invoke(pwb, "Name") . """,""" . COM_Invoke(pwb, "FullName") . """`n", COM_Release(pwb) 
COM_Release(psw) 
COM_Release(psh) 
COM_Term() 

MsgBox, % sInfo

This produces COM errors ("Function Name: "hWnd"")
when Steam is running. Steam is using an IEFrame, so I suppose this might be related. Any idea what could be done to fix this? Personally, I am only interested in getting explorer windows. Maybe there is an explorer specific interface that could be queried or so before calling hwnd?
I already tried contacting Steam devs about this, but they don't want to investigate this from their side.

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
What is the exact error message? And have you rebooted your computer and tried the code again?

Although a portion of that code is used in the iWeb_getWin function, that specific code doesn't really have much to do with this topic (other than tank linking to it in the old thread).

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
---------------------------
COM Error Notification
---------------------------
Function Name: "hWnd"
ERROR: Unbekannter Fehler

(0x80004005)
PROG:
DESC:
HELP: ,0

Will Continue?
---------------------------
Ja Nein
---------------------------

I tried rebooting, restarting Steam etc. this is perfectly reproducable and only happens when Steam is running. I should probably also say that I'm running Win7 32Bit. I use similar code that navigates active Explorer window, and I also see the error there. With that code it sometimes also happens when called at "unusual" places (that is, during a folder change, when closing explorer window, and I believe also sometimes in control panel, however, those happen a bit too infrequently to verify for sure what causes them).
Explorer windows that were started before Steam are not affected, probably because they are listed before the Steam IEFrame and my code breaks when it finds the correct window, so Hwnd is not called on the IEFrame of Steam.

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

Personally, I am only interested in getting explorer windows. Maybe there is an explorer specific interface that could be queried or so before calling hwnd?

I would use something like this to filter out IE windows:
If pwb := COM_Invoke(psw, "Item", A_Index-1) ; ensure pwb isn't "empty"
	If Not InStr( COM_Invoke(pwb, "FullName"), "iexplore.exe" ) ; ensure pwb isn't IE


sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Why do you need to retrieve the windows using the hWnd?

It looks like you've already covered this ground with Sean and I don't think anyone in this thread is more qualified to answer questions about this than he is. We can't answer every question about why some programs don't respond properly to a COM call, particularly when it's classified as an unknown error.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
If pwb := COM_Invoke(psw, "Item", A_Index-1) ; ensure pwb isn't "empty" 
   If Not InStr( COM_Invoke(pwb, "FullName"), "Steam.exe" ) ; ensure pwb isn't Steam

This works very good, thank you!

I used hWnd because I wanted to capture the active window, and this seemed like the safest way.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
and yet it isnt even relavant to the active window the way your retreiving it
IEGet from the first page of this thread is the very best way to get the top most browser window
also passing a blank name to iweb_getwin will as well
Never lose.
WIN or LEARN.