Sign in to follow this  
Followers 0
syundiers

Ieaction Click problems!

12 posts in this topic

Hi all,

I am trying to auto populate a file upload form on my site, I have declared my variable for the button name and using the code:

_IEAction($oButton, "click")

the button is clicked and the file dialog box appears, great. The problem is none of my code after this seems to work, i am using send commands to populate the dialog box but it isnt working. I have also tried using the WinWaitActive function but that doesnt seem to work either. No errors appear in my debug box..

Any ideas?

thanks

Share this post


Link to post
Share on other sites



post some code?

Share this post


Link to post
Share on other sites

Sure sorry..

$oButton = _IEGetObjByName($o_form, "file")

_IEAction($obutton, "click")

send("c:\hello.jpg")

File dialog box pops open but the text isnt sent to it..

I have also tried:

$oButton = _IEGetObjByName($o_form, "file")

_IEAction($obutton, "click")
WinWaitActive("Choose file")

send("c:\hello.jpg")

But no joy still :/

Share this post


Link to post
Share on other sites

To what are you trying to send that text ? Post some source code of the page please.

Share this post


Link to post
Share on other sites

I am trying to send the file location, once the button is pressed a "choose file" dialog appears when i would normally select the file for upload, i am trying to automatically populate that box with text.

<form id="form" enctype="multipart/form-data" action="/upload" method="post">
 <input id="form1" name="file" type="file" size="90" />
</form>

the dialog box opens fine, but the text doesnt get entered.

thanks.

Share this post


Link to post
Share on other sites

$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("input")

for $element in $oArray
if $element.id="form1" then 
_IEAction($element, "focus")
Send("C:\myfile.txt")
endif
next

Try this one if it works

Share this post


Link to post
Share on other sites

Thanks for your reply. It seems to focus in on the button, but it does not 'get focus' so to speak, and it pastes the text, but in the url box!

Share this post


Link to post
Share on other sites

See example 2 for _IEAction

; Example 2 - Same as Example 1, except instead of using click, give the element focus

; and then use ControlSend to send Enter. Use this technique when the

; browser-side scripting associated with a click action prevents control

; from being automatically returned to your code.

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

Thanks for the help guys.

I have tried using the "focus" action, for some reason it just focus'es in on the element but doesnt actually set it as the active object? so it moves the display to it, but the cursor is still in the url bar.. any reason for this?

Thanks

Share this post


Link to post
Share on other sites

$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("input")
$hwnd = _IEPropertyGet($oIE, "hwnd")

for $element in $oArray
if $element.id="form1" then
_IEAction($element, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\myfile.txt")
endif
next

Try this one

Share this post


Link to post
Share on other sites

That seems to have done it!

Thankyou so much, this was begining to annoy me!

Just out of interest, how come the WinWaitActive("Choose file") doesnt work? even though the open file dialog had the title of "Choose file"?

Share this post


Link to post
Share on other sites

I think it works but after that when you use the "send" it doesnt send to the correct window control.

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