Jump to content

Enter value into FORM 'file' INPUT when IE hidden?


plastix
 Share

Recommended Posts

Hi all,

Automating a form submission, and have got it working nicely (inc. INPUT type="file") using focus etc... I had 2 methods of entering data into the 'file' field...

$ffield = _IEFormElementGetObjByName ($oForm, "file")
_IEAction($ffield, "focus")
Send($file) ;$file contains path to file
While 1
 _IEAction($ffield, "focus")
 $infile = _IEFormElementGetValue ($ffield)
 If $infile = $file Then ExitLoop
   Sleep(100)
WEnd

Of course, they both work while IE is visible, but if I use _IECreate with visible = 0, then focus no longer appears to work. Is there any workaround, otherwise I will keep visible.

TIA as ever

PS- thanks again DaleHohm for this library ;)

Link to comment
Share on other sites

You can either use ControlSend, or more appropriately, _IEFormElementSetValue.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

_IEFormElementSetValue won't work on INPUT TYPE=file fields due to security restrictions imposed by the browser.

As Mike points out, I believe that ControlSend should work. Give focus to the element, then use ControlSend -- the control name to use is "Internet Explorer_Server1".

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

Link to comment
Share on other sites

Good thing Dale is around to point out the things I don't know ;)

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Learn and share Mike, learn and share. Thanks for jumping in.

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

Link to comment
Share on other sites

Try:

ControlFocus("Microsoft Internet Explorer","","Internet Explorer_Server1")
ControlSend("Microsoft Internet Explorer","","Internet Explorer_Server1",$file,1)
oÝ÷ Ùú+ N®«ªljëh×6
_IEAction($ffield, "focus")
ControlSend("Microsoft Internet Explorer","","Internet Explorer_Server1",$file,1)

;Or

_IEAction($ffield, "focus")
ControlSend("Microsoft Internet Explorer","","",$file,1)

Hopefully one of those works for you.

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...