Jump to content
Sign in to follow this  
monoceres

Another IE help topic

Recommended Posts

monoceres

I'm currently writing a script for a friend, it's supposed to log into his profile on a pic sharing community and upload pictures. The problem is with the forms (they never act like you want them to...). I can't write to a textarea on the upload page, I know the name and everything (text) but it just won't set the data :D

Here's my script:

#include <IE.au3>
;~ $user=InputBox("BDB användarnamn","Skriv in ditt BDB användarnamn")
;~ $pass=InputBox("BDB lösenord","Skriv in ditt lösenord","","*")
$user="developaccount"
$pass="supersecretpassword"
$browser=_IECreate("http://www.bilddagboken.se")
$loginform = _IEFormGetObjByName ($browser, "loginForm")
$userform=_IEFormElementGetObjByName($loginform,"user")
$passform=_IEFormElementGetObjByName($loginform,"pass")
_IEFormElementSetValue($userform,$user)
_IEFormElementSetValue($passform,$pass)
_IEFormSubmit ($loginform)
_IENavigate($browser,"http://"&$user&".bilddagboken.se/p/upload.html")
$theForm=_IEFormGetObjByName($browser,"theForm")
$fileform=_IEFormElementGetObjByName($theForm,"filen")
$textform=_IEFormElementGetObjByName($theForm,"text")
_IEFormElementSetValue($textform,"test")
_IEAction($fileform, "focus")
$hIE = _IEPropertyGet($browser, "hwnd")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\mypic.jpg")

The page is in swedish but if you just let script finish you will have the textarea right in front of you :)

Thanks for all input :(


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
DaleHohm

It's not a text area. It is an entire document in an iFrame.

$oFrame = _IEFrameGetObjByName($oIE, "text")

_IEBodyWriteText($oFrame, "Hello IE")

_IEBodyWriteHTML($oFrame, "Hello IE")

Dale

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
monoceres

Hmm I can't get it to work. It seems like there are no frames, I tried with _IEFrameGetCollection () but it didn't return anything. I also seems like I don't have _IEBodyWriteText() on my system.

Thanks for your answer :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
DaleHohm

My bad, _IEBodyWriteHTML

DebugBar quickly reveals it is an iFrame... give it a try if you are not using it (see my sig).

There may be more frame nesting, so "text" may not be a frme in the main document. Again, DebugBar should help you find the structure.

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
monoceres

Thanks so much for your help :)

I got it working now thanks to DebugBar.

Just one more question then I will be completely satisfied, any ideas how to submit all the data?

Normally you do this by clicking the "Ladda upp" button but I can't simulate a click on it :(

I also tried to submit the big form (the one that contains the file input) with no success.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
monoceres

Bump!

I really need some help with this. :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
DaleHohm

Why can't you simulate a click on that button? What have you tried? What comes back to the SciTe console? You're using _IEAction, click right?

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
monoceres

The problem is that I can't seem to get the button object, this is what debugbar says about the button:

<A class=button id=uploadButton style="MARGIN-TOP: 15px; FLOAT: right" jQuery1211043979221="8"><SPAN>Ladda upp</SPAN></A>

There are also some hidden inputs, named action, upload and MAX_FILE_SIZE, not sure if they have anything to with this.

I also tried _IEImgClick().


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
monoceres

I finally got it working :)

Used _IEGetObjById() to get the obj to the button.

@DaleHohm: Thank you very much for your support, not only did you write a very good UDF but you also help people with it.

Really appreciated!


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
DaleHohm

You're welcome. Glad you figured it out.

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

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  

×