Sign in to follow this  
Followers 0
BotBuddy

Need Help with _IEFormElementSetValue or Input type=file.

3 posts in this topic

Hi Mates

I am new here, new to AutoIT & Automation.

This is my first try at AutoIT

I have created a script to upload some image files to my account

Here is the code,

#include
#include
#include
#include
#include
#include
#include
#include

$path = 'E:\HotUpload\1.jpg'
$ie = _IECreate( 'http://www.imgchili.com/')
_IEErrorNotify(False)
_IEErrorHandlerRegister()
$oForms = _IEFormGetCollection($ie)

;Debug Code to get fom info
ConsoleWrite( "Forms Info There are " & @extended & " forms on this page" & @CRLF)
For $oForm In $oForms
ConsoleWrite( "Form Info " & $oForm.name & @CRLF)
Next
ConsoleWrite("End loop of IE Forms" & @CRLF)
;There ae total of 1 form and its name is 0

$Index = 0
For $oForm In $oForms
$oFormElements = _IEFormElementGetCollection($oForm)
If IsObj($oFormElements) Then
$IndexElement = 0
For $oElement In $oFormElements
If $oElement.Type = 'file' Then
$oPath = _IEFormElementGetObjByName($oElement, $oElement.Name, $indexElement+1)

$oElement.fireEvent("onmouseover")
$iBrowserX = _IEPropertyGet($oElement, "browserx")
$iBrowserY = _IEPropertyGet($oElement, "browsery")
$iWidth = _IEPropertyGet($oElement, "width")
$iHeight = _IEPropertyGet($oElement, "height")

ControlClick(_IEPropertyGet($IE, "hwnd"), "", "", "left", 1, $iBrowserX + $iWidth/2, $iBrowserY + $iHeight/2)
;ControlSetText(_IEPropertyGet($IE, "hwnd"), "", "",$path)

_IEFormElementSetValue($oPath, $path)
ExitLoop
EndIf
$IndexElement += 1
Next
EndIf
$Index += 1
Next

The problem is after executing the script, I get my cursor at the input fiels but my text specified in $path is not set.

I have tried ControlSetText & _IEFormElementSetValue.

But I can't set the Text.

Is there any way to do this? Any othe function or method?

Thanks.

Share this post


Link to post
Share on other sites



It's a known security issue. Read the entire help file entry for _IEFormElementSetValue.

Share this post


Link to post
Share on other sites

See my sig for suggestions.

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  
Followers 0