Sign in to follow this  
Followers 0
psychoblast

How to get form ID from IE

3 posts in this topic

#1 ·  Posted (edited)

Trying to make a youtube browser and need a script to be able to comment on youtube without actually clicking on the box and pressing comment. Here is what I have so far:

#include <IE.au3>
$oIE = _IECreate("http://www.youtube.com/watch?v=Nl4opbNt8_E")
_IELoadWait($oIE)
$oForm = _IEFormGetObjByName ($oIE, "textarea")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "comment")
$uname="Yourusername"
_IEFormElementSetValue ($oQuery1,$uname)

$oForm1 = _IEFormGetCollection($oIE, 0)
$oQuery = _IEFormElementGetCollection($oForm1, 1)

might be way off but so far it opens up IE to a youtube video Cant seem to get the form ID for the textfield for the comment.

also in google chrome when you click inspect element for the texfield I get this:

<textarea onfocus="yt.www.comments.initForm(this);" class="yt-uix-form-textarea comments-textarea" name="comment"></textarea>

Here I also have a similar script but I am not sure I am going in the right direction:

#include <IE.au3>
$oIE = _IECreate("http://www.youtube.com/watch?v=Nl4opbNt8_E")
_IELoadWait($oIE)
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("input")
For $element In $oArray
If $element.Name = "comment" Then
_IEFormElementSetValue($element, "hello")
msgbox(0,"","Found it")
Endif
Next
Edited by psychoblast

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Really close to getting it to work. Got the elements' names just one problem. If I want to comment i have to first click on the textbox i tried using IEAction and use click but it doesnt click on the textbox here is what I got:

#include<IE.au3>
_IEErrorHandlerRegister()
_IELoadWaitTimeout(5000)
$oIE=_IECreate("http://www.youtube.com/watch?v=JjmeSwPig_8",0,1,1)
$oForm=_IEGetObjByName($oIE,"comment")
_IEAction($oForm, "click")
$oSubmit=_IEGetObjByName($oIE,"submit")
_IEFormElementSetValue($oForm,"Thanks")
_IEAction($oSubmit,"click")
_IEErrorHandlerDeRegister()

edit: got that to work usign IEAtction focus. but now the button won't click. Here is the latest script:

#include<IE.au3>
_IEErrorHandlerRegister()
_IELoadWaitTimeout(5000)
$oIE=_IECreate("http://www.youtube.com/watch?v=JjmeSwPig_8",0,1,1)
$oForm=_IEGetObjByName($oIE,"comment")
_IEAction($oForm, "focus")
_IEFormSubmit($oForm)
$oSubmit=_IEGetObjByName($oIE,"add_comment")
_IEFormElementSetValue($oForm,"Thanks")
_IEAction($oSubmit,"click")
_IEErrorHandlerDeRegister()

Only thing I seem to be missing is the name for the post button. any help finding it?

Edited by psychoblast

Share this post


Link to post
Share on other sites

apologize for triple post but I solved it. Thanks for all your help :/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0