Sign in to follow this  
Followers 0
Noobster24

Use IE.au3 with this form

16 posts in this topic

#1 ·  Posted (edited)

Hi guys,

i use DaleHohm's IE.au3 file in my programs to submit forms etc.

Now i found this form on a website, and i know it's crappy HTML scripting:

<form action=/index.php method=post>

<input size=20 name=chto value="">

<input type=submit value="Search" class="knp">

</form>

How can I set the value in chto and how can i submit the form, using IE.au3? (v1.0)

If i do it like this it works perfectly..

Form:

<form action="search.php" method="post" name="search">
<input name="q" type="text" />
<input type="submit" value="Search" />
<input name="post" type="hidden" />
</form>

#include <IE.au3>
#include <File.au3>
#include <FTP.au3>

; Create an invisible IE
$oIE = _IECreate(0)
$sq = "norton"
_IENavigate($oIE, "http://localhost/~ OSS ~/search.php")
$o_form = _IEFormGetObjByName ($oIE, "search")
$o_login = _IEFormElementGetObjByName ($o_form, "q")    
_IEFormElementSetValue ($o_login, $sq)
_IEFormSubmit($o_form)
Sleep(150)
$source = _IEBodyReadHTML($oIE)
$filec = _FileCreate(@ScriptDir & "\list.txt")
$file = FileOpen(@ScriptDir & "\list.txt", 1)     
FileWrite($file, $source)   

_IEQuit($oIE)

It works because i've given the form a name, but with the form i found on the i-net there didn't give the form a name, so maybe DaleHohm himself knows the answer... :D:D:P

Greetings,

Andreas

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites



...It works because i've given the form a name, but with the form i found on the i-net there didn't give the form a name, so maybe DaleHohm himself knows the answer...

Fast help, since not much time:

Everything can have a name, but everything will always have a number!

So: look for something like:

(retrieve form.length)

get form[0] (always start the first with a zero)

just look on websites about javascript..

I hope it gets you going...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Fast help, since not much time:

Everything can have a name, but everything will always have a number!

So: look for something like:

(retrieve form.length)

get form[0] (always start the first with a zero)

just look on websites about javascript..

I hope it gets you going...

Wow, in one second i found this website:

http://www.quirksmode.org/js/forms.html

But that's in Javascript, i need to implant this into AutoIt...

To submit the form in java script:

document.forms[0].submit()

But how do i set the value of a from in Javascript if it isn't your website, eg.

I could put this Javascript code in my webpage:

var sq = 'norton'
document.forms[0].chto.value = var sq;

But the website i want to set the value in the form isn't my website so i can't put this javascript in the source...

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

var sq = 'norton'

document.forms[0].chto.value = var sq;

But the website i want to set the value in the form isn't my website so i can't put this javascript in the source...

think this: form[0] is the first form

every form has 1 or more 'elements', all have a number once again... so something with

.?.....forms.item(0).item(0).value=var sq (or something...)

HTH

Share this post


Link to post
Share on other sites

think this: form[0] is the first form

every form has 1 or more 'elements', all have a number once again... so something with

.?.....forms.item(0).item(0).value=var sq (or something...)

HTH

Yep i know, but how do i let AutoIt do that? I know the Javascript part, but AutoIt isn't Javascript :D

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yep i know, but how do i let AutoIt do that? I know the Javascript part, but AutoIt isn't Javascript :D

This is in Javascript the field i need to set the value to:

document.forms[0].elements[0].value = 'The new value';

I want to set the value with AutoIt in combination with Javascript... :D

Is that possible?

//I'm must eat now, be back in one hour..

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Yep i know, but how do i let AutoIt do that? I know the Javascript part, but AutoIt isn't Javascript :D

Mmm, perhaps Dale's IE-stuff does not like index-numbers that much right now.

As far I can think (quickly): do use the javascript! Just put the $oIE in front like

$oIE.document.forms.index(0) etc..

or $oIE.document.all.forms[0].item[0].value=$myvar ...

or $oIE.document.forms[0].elements[0].value = 'The new value';

something like that...?

Edited by heibel

Share this post


Link to post
Share on other sites

Mmm, perhaps Dale's IE-stuff does not like index-numbers that much right now.

As far I can think (quickly): do use the javascript! Just put the $oIE in front like

$oIE.document.forms.index(0) etc..

or $oIE.document.all.forms[0].item[0].value=$myvar ...

or $oIE.document.forms[0].elements[0].value = 'The new value';

something like that...?

Hi, i'm back, fresh and sharp :D, i'll try what you said :D

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hi, i'm back, fresh and sharp :P, i'll try what you said :mad:

Wow, this seems to work ;):D:D:evil::mad2:

;InetGet("http://localhost/images/logo.jpg", "C:\log.jpg", 1)
;#include <INet.au3>
;ConsoleWrite(_INetGetSource('www.autoitscript.com'))

#include <IE.au3>
#include <File.au3>
#include <FTP.au3>

; Create IE
$oIE = _IECreate(1)
_IENavigate($oIE, "http://localhost/~ OSS ~/search.php")
$sq = "norton"
$oIE.document.forms(0).elements(0).value = 'norton'
Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Wow, this seems to work :P:D:D;):evil:

;InetGet("http://localhost/images/logo.jpg", "C:\log.jpg", 1)
;#include <INet.au3>
;ConsoleWrite(_INetGetSource('www.autoitscript.com'))

#include <IE.au3>
#include <File.au3>
#include <FTP.au3>

; Create IE
$oIE = _IECreate(1)
_IENavigate($oIE, "http://localhost/~ OSS ~/search.php")
$sq = "norton"
$oIE.document.forms(0).elements(0).value = 'norton'
Just one question... :mad2:

In this form (the crappy scripting form..:x ):

<FORM action=/index.php method=post><INPUT value=norton name=chto> <INPUT class=knp type=submit value=Search> </FORM>

The value is set as you can see :mad:, but the page isn't submit with:

$oIE.document.forms(0).submit

How must i submit the form?


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

IE.au3 can access items by name or by index value.

To access by index in T2.0, use the *GetCollection() routines and specify the index number. For example, to get a reference to the first form on the page (the numbering starts with 0):

$oForm = _IEFormGetCollection($oIE, 0)

T1.0 had a function _IEFormGetObjByIndex, but T2.0 combines that functionality into _IEFormGetCollection.

Dale

Edit: removed OP text

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

The value is set as you can see :D, but the page isn't submit with:

$oIE.document.forms(0).submit

How must i submit the form?

? try submit() instead of submit...

so: $oIE.document.forms(0).submit()

good you got it working!

Oh and for all this stuff, search and download some info called the 'DOM' (that & browser: stands for all this sort of possability's/language-stuff you can use...)

Edited by heibel

Share this post


Link to post
Share on other sites

IE.au3 can access items by name or by index value.

Also for the SetFormObject (or something)?

He, and thanks for the incredible bug-fix: works like a charm!

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

IE.au3 can access items by name or by index value.

To access by index in T2.0, use the *GetCollection() routines and specify the index number. For example, to get a reference to the first form on the page (the numbering starts with 0):

$oForm = _IEFormGetCollection($oIE, 0)

T1.0 had a function _IEFormGetObjByIndex, but T2.0 combines that functionality into _IEFormGetCollection.

Dale

Edit: removed OP text

The problem with T2.0 is, that when i want to use the function _IECreate(), it gives a error,

example:

#include <IE.beta.au3>
#include <File.au3>
#include <FTP.au3>

; Create an invisible IE
$oIE = _IECreate("http://localhost/~ OSS ~/search.php",0,0)
$sq = 'norton'
$oIE.document.forms(0).elements(0).value = $sq
$oIE.document.forms(0).submit()
Sleep(150)
$source = _IEBodyReadHTML($oIE)
_IEQuit($oIE)
$filec = _FileCreate(@ScriptDir & "\norton.txt")
$file = FileOpen(@ScriptDir & "\norton.txt", 1)   
FileWrite($file, $source)

It looks to me that this code is okay, but this error shows up:

+>AU3Check ended.rc:0
>Running:(3.1.1.126):D:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\Beheerder\Bureaublad\Andreas\Custom Cracks\~ OSS ~\poeppages\testt2.0.au3"    
--> IE.au3 Warning from function _IECreate (Foreground Window Unlock Failed!)
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 1.842

I've got the latest AutoIt beta version (v3.1.1.126 (beta)), i've got the latest IE UDF Library...

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

The problem with T2.0 is, that when i want to use the function _IECreate(), it gives a error,

Sorry, everything is working fine, the Warning is in error not the code... LOULOU reported this a couple of days ago and you'll find a note at the end of the T2.0 post stating that this is know and is fixed for the next reslease. The mistake on my part is taht I display the warning anytime you set takeFocus to 0 regardless of whether it works or not.

If you want to, you can suppress the warning by wrapping _IEErrorNotify(False) and _IEErrorNotify(True) around your _IECreate().

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Sorry, everything is working fine, the Warning is in error not the code... LOULOU reported this a couple of days ago and you'll find a note at the end of the T2.0 post stating that this is know and is fixed for the next reslease. The mistake on my part is taht I display the warning anytime you set takeFocus to 0 regardless of whether it works or not.

If you want to, you can suppress the warning by wrapping _IEErrorNotify(False) and _IEErrorNotify(True) around your _IECreate().

Dale

I'll wait for the next release, T1.0 is still working fine :D:D!

Thanks guys :D


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

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