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
DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006
Hi all.
I have a few questions I am stuck on.
1. Is there any way to get the title of a page via COM?
2. is there any way to read the page, get the elements, and sort them from first found to last found, and only get the element if its a text box or textarea? You see, the name changes and so does the id.
They only have these Unique parts...
First "tabIndex=1 maxLength=89 size=50"
Second "tabIndex=1 maxLength=57"
Third "rows=14 cols=88"
The third one is the text area.
3. Is there a way to get the link of the currently open web page after its loaded?
4. After getting the link of an image with iWeb_getDomObj(pwb,"39"), how could I download it?
5. I want to make a script that would do auto captcha filling.. Using an account with decaptcher and
runwait, decaptcherexe.exe -l my account -p mypassword -h api.decaptcher.com -t myport -c c:\image.jpg
fileread, answer.txt
and then I want to do like a CTRL then click every time I get those stupid things, pay to have it solved through decaptcher, then type it in through COM and have it click the default button of that page.. So the script will have to learn the current pages default ID to click ok, kind of like iWebBrowser2 Learner.exe does, and then download the image, get it solved, enter the text, click the default button and get past the darn thing.
Ya, I know, I am a freak, but I hate those things though and the script would have to be universal enough to deal with the different sites that use them.. Seriously, I would rather have the script running in the back ground, do a ctrl click a few times to activated it, do soemthine else while decaptcher solves it, then come back in a few minutes and continue doing what I was doing before the damn thing interupted my life! :twisted:
Thank you very much for your time.

DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006
uuuuummmm; what, did I ask t000000ooooo much?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
you mentioned cracking captcha which even i wont help with
Never lose.
WIN or LEARN.

DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006

you mentioned cracking captcha which even i wont help with

But DUDE!! :p Those things SUCK! I got to do at least 10-20 a day just to do my work.
Collectively, we could solve world hunger with all the waisted time.

:roll: :wink:

KK, when then what about,
1. Is there any way to get the title of a page via COM?

3. Is there a way to get the link of the currently open web page after its loaded? (more info....I think I understand how to get the link before the page is loaded, but not after. My web site is built on old school ASP and when I go to it, I get a number. That number sticks with my clients all the way through to the end of the shopping cart and even to where they dl my remote helpdesk software and log into me. That number would be really cool to get so I can make sure no one steals my software. It's also in my Access database so it would help identify each client.)

Thankyou.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
com_invoke(pwb,"locationname")
com_invoke(pwb,"locationURL")

Never lose.
WIN or LEARN.

tinku99
  • Members
  • 560 posts
  • Last active: Feb 08 2015 12:54 AM
  • Joined: 03 Aug 2007
Is it possible to inject vbscript into IE instead of injecting javascript ?

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
I know you can to a certain extent anyways:
vbscript: alert("Hello World!")
vbscript: MsgBox("Hello World!") ; causes navigation
... & of course a good resource is W3schools ...

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
esecscript supports vbscript as well as jscript. execscript MSDN

vbscode = msgbox "VBS"
com_invoke(pwb,"document.parentwindow.execscript",vbscode,"VBScript")

thanks for catching the s instead of x
Never lose.
WIN or LEARN.

tinku99
  • Members
  • 560 posts
  • Last active: Feb 08 2015 12:54 AM
  • Joined: 03 Aug 2007

vbscode = msgbox "VBS"

com_invoke(pwb,"document.parentwindow.execscript",vbscode,"VBScript")

works beautifully. Thanks.

ecksphore
  • Members
  • 252 posts
  • Last active: Jul 20 2015 03:25 AM
  • Joined: 21 Nov 2006
MsgBox % COM_Invoke(pwb, "document.all.user_name.value")

If the 'element' name is "user_name" and the 'type' is set to "hidden", is there any way to still grab the value(s)?

The code above won't do that. Thanks.

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

The code above won't do that.

That is a very general problem to have :p - without a specific example (code+webpage/html), or a more detailed error report, my guess is there is more than one element with that name. Does this code give you the data you want?
coll := COM_Invoke(pwb, [color=#666666]"document.all.user_name"[/color])

[color=#107095]Loop[/color], % COM_Invoke(coll, [color=#666666]"length"[/color])
	data .= [color=#666666]"["[/color] [color=brown]A_Index[/color]-1 [color=#666666]"].value = """[/color] COM_Invoke(coll, [color=#666666]"item["[/color] [color=brown]A_Index[/color]-1 [color=#666666]"].value"[/color]) [color=#666666]"""`n"[/color]
[color=#107095]MsgBox[/color], 0, document.all.user_name, %data%

COM_Release(coll)


ecksphore
  • Members
  • 252 posts
  • Last active: Jul 20 2015 03:25 AM
  • Joined: 21 Nov 2006

The code above won't do that.

That is a very general problem to have :p - without a specific example (code+webpage/html), or a more detailed error report, my guess is there is more than one element with that name. Does this code give you the data you want?
coll := COM_Invoke(pwb, [color=#666666]"document.all.user_name"[/color])

[color=#107095]Loop[/color], % COM_Invoke(coll, [color=#666666]"length"[/color])
	data .= [color=#666666]"["[/color] [color=brown]A_Index[/color]-1 [color=#666666]"].value = """[/color] COM_Invoke(coll, [color=#666666]"item["[/color] [color=brown]A_Index[/color]-1 [color=#666666]"].value"[/color]) [color=#666666]"""`n"[/color]
[color=#107095]MsgBox[/color], 0, document.all.user_name, %data%

COM_Release(coll)


That did the trick!

NewBie21
  • Guests
  • Last active:
  • Joined: --
I'm trying to click on a element - but depending on the page reload, it could belong to any one of 6 forms (that has no name).

javascript: document.getElementByName('id_tag').click()

Am I doing right? I'm not able to get it to click on it.



I am able to get it to click though by doing this :

javascript: document.forms[2].elements[5].click()

But I was hoping I didn't have to know what form# it belongs too - because that changes everytime.

Newbie21
  • Guests
  • Last active:
  • Joined: --
Could someone please tell me what I am doing wrong here?

Loop
{
	count = 0
	name := COM_Invoke(pwb, "document.forms[%count%].elements[5].name")
	If name =
		break
	MsgBox, Form #%count% = %name%
	count++
}


Newbie21
  • Guests
  • Last active:
  • Joined: --

Could someone please tell me what I am doing wrong here?

Loop
{
	count = 0
	name := COM_Invoke(pwb, "document.forms[%count%].elements[5].name")
	If name =
		break
	MsgBox, Form #%count% = %name%
	count++
}


The count = 0 wasn't supposed to be in that loop - pasting error

the var "count" is being up an error screen.