LOULOU Posted April 9, 2009 Share Posted April 9, 2009 Under IE 7 it was possible to control an imput type=file with the following sentence : ; Assign input focus to the field and then send the text string $fichier = _IEFormElementGetObjByName($form, "nomFic") _IEAction($fichier, "focus") $hie = _IEPropertyGet($oIE, "hwnd") ControlSend($hie, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", StringUpper($file)) On IE8 these sentences doesn't work Is someone knows how to do to send directly a sentence into the imput file ? Link to comment Share on other sites More sharing options...
DaleHohm Posted April 9, 2009 Share Posted April 9, 2009 It appears Microsoft is making the world safe again... this works fine for other form fields, but they have done something in IE8 to prevent synthetic input like this. I have no idea how at this point. I'll keep my eyes open for other ways around this, but invite anyone else to take a look around for discussions of this. You'll see in the following example that text fields other than the type=file work as expected. #include <IE.au3> $oIE = _IE_Example("form") $oField = _IEGetObjByName($oIE, "fileExample") ; this doesn't do what it used to do, no text in field ;$oField = _IEGetObjByName($oIE, "textExample") ; this one works _IEAction($oField, "focus") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "Foo.Bar") ; with focus on type=file, text does not appear 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 More sharing options...
LOULOU Posted April 10, 2009 Author Share Posted April 10, 2009 (edited) Here is a beginning of answering <html> <head></head> <body> <form name="test_form" method="post" action="test.asp"> <input type=file name=browse style="display: none;"> <input type=text name=file> <input type=button style="font-style:veranda; font-size:12px; font-weight:bold;text-transform:lowercase;color:white;background-color:#A2C382;height:22px;border-style:ridge;text-align:center;" onclick="browse.disabled=false;browse.click();file.value=browse.value;browse.disabled=true" value="Select a File..."> <br><br> <input type=submit value="Submit The Form Now!" style="font-style:veranda; font-size:12px;"> </form> </body> </html> Edited April 10, 2009 by LOULOU Link to comment Share on other sites More sharing options...
DaleHohm Posted April 10, 2009 Share Posted April 10, 2009 > Here is a beginning of answering I have no idea what you are trying to say 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 More sharing options...
LOULOU Posted April 11, 2009 Author Share Posted April 11, 2009 > Here is a beginning of answering I have no idea what you are trying to sayDaleThis allow to style input type=file and solving the problem of input type=fileI will show if that's working on Monday and after i will say it to youThanks Link to comment Share on other sites More sharing options...
Aeterna Posted April 20, 2009 Share Posted April 20, 2009 CODE$oUpload = _IEGetObjByName($oIE, "NameOfFileUpload") _IEAction($oUpload, "focus") Send("{SPACE}") Link to comment Share on other sites More sharing options...
Elizeu Posted September 30, 2009 Share Posted September 30, 2009 Thanks Aeterna , your code works fine to me ;-) My script: ;================================= $o_form = _IEFormGetObjByName ($oIE, 0) ; Colocar "f1" quando se tem um nome no Formulario $oUpload = _IEGetObjByName($o_form, "txtArquivo1") _IEAction($oUpload, "focus") Send("{SPACE}") Sleep(5000) Send($caminho_arq_retorno) ; C:/Folder/File.txt Sleep(5000) Send("{Enter}") Sleep(5000) $o_botao = _IEFormElementGetObjByName ($o_form, "cmdEnviar") _IEAction ($o_botao, "click") ;================================= Link to comment Share on other sites More sharing options...
mikeyr Posted October 1, 2009 Share Posted October 1, 2009 Damm that was easy, I trying to get window handles and object names and stuff like that and could not get it to work. Thanks ! it works. Link to comment Share on other sites More sharing options...
DaleHohm Posted November 17, 2009 Share Posted November 17, 2009 OK, here is another example: #include <IE.au3> $oIE = _IE_Example("form") $oT = _IEGetObjById($oIE, 'fileExample') MouseMove(_IEPropertyGet($oT, "screenx") + _IEPropertyGet($oT, "width") - 10, _ _IEPropertyGet($oT, "screeny") + _IEPropertyGet($oT, "height")/2) MouseClick("left") WinWait("Choose File to Upload") $hChoose = WinGetHandle("Choose File to Upload") ControlSetText($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick($hChoose, "", "Button2") 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 More sharing options...
Lexxicon Posted December 8, 2009 Share Posted December 8, 2009 Tried both of these methods... On Win XP Pro (latest Patches and Packs) in IE8 #include <IE.au3> $oIE = _IE_Example("form") $o_form = _IEFormGetObjByName ($oIE, 0) ; First Form Object $oUpload = _IEGetObjByName($o_form, "fileExample") _IEAction($oUpload, "focus") Send("{SPACE}") Sleep(5000) Send("C:\DEV\Session.txt") ; C:/Folder/File.txt Sleep(5000) Send("{Enter}") Sleep(5000) This First one did not work, it simply displayed Session.txt in my Explorer Window because IEAction focus line set the focus to the Address Bar and not the control. The Second example supplied (by Dale) worked only in the very simple _IE_Example form but did not work on other 'real' websites. I found that the MouseClick("Left") is the last line executed (The 'Choose File' sub-form comes up and just sits there) with WinWait never coming back. We still need an example that works on other websites and I have found nothing else in the forums so far. It looks like AutoIT just never sees the spawned Window as WinList() will not even execute until you first cancel out of the the Choose File window. Any other thoughts? Link to comment Share on other sites More sharing options...
DaleHohm Posted December 8, 2009 Share Posted December 8, 2009 but did not work on other 'real' websitesDid not work doesn't cut it. Provide a reproducer if you want assistance.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 More sharing options...
Lexxicon Posted December 9, 2009 Share Posted December 9, 2009 Hi Dale, Appreciate your help. Please try http://www.cs.tut.fi/~jkorpela/forms/file.html where the field is the one under "Chose File". I have tried all manner of ways to update the file field but failed. Reproducer: I have a cut down one of the embedded object we are currently trying to get working below which clearly demonstrates this behaviour and uses the same coding approach as you have demonstrated. #include <IE.au3> $oIE = _IECreateEmbedded () GUICreate ("Test") GUICtrlCreateObj ($oIE, 0, 0, 1024, 768) GUISetState (@SW_SHOW) _IENavigate ($oIE, "C:\DEV\Test.html") $oT = _IEGetObjById ($oIE, 'fileExample') MouseMove (_IEPropertyGet ($oT, "screenx") + _IEPropertyGet ($oT, "width") - 10, _IEPropertyGet ($oT, "screeny") + _IEPropertyGet ($oT, "height") / 2) MouseClick ("left") WinWait ("Choose File to Upload") $hChoose = WinGetHandle ("Choose File to Upload") ControlSetText ($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick ($hChoose, "", "Button2") The Test.html file is simply the View Source of your own 'Example form' output to a file so as to create an HTML page external to the script (i.e. not created by the script itself). The code never comes back from the WinWait for me. Let me know if you can get it working. Link to comment Share on other sites More sharing options...
DaleHohm Posted December 9, 2009 Share Posted December 9, 2009 That is a very large and dense HTML page and I do not see "Chose File" or "Choose File" on it anywhere. 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 More sharing options...
Lexxicon Posted December 10, 2009 Share Posted December 10, 2009 Hi Dale,I have attached the Test.html file, incase you want to use the original Reproducer I sent in the last post.The external website I supplied teaches people to create websites so I think this is a good 'typical' example of how many people are coding this function.It has the 'Choose File' button in the green box following the text "And on your browser, with its current settings, and as possibly affected by my stylesheet, this is what the form looks like". There are several other "Choose file" examples on this page, but any one of these would have the same issue as they are all of type " input type='file' name='fileExample' if you view their source". If you can get any of these to change then it should work for all of them.NB: Rather than have you waste time looking at this complex site I have produced a simple website page for you so you can test it directly on our own website http://www.dobeash.com/test.html and here is the Reproducer code for testing one this. Let me know if I can assist in any other way as we are very keen to have a working way to access this type of file control consistently.#include <IE.au3> $oIE = _IECreateEmbedded () GUICreate ("Test") GUICtrlCreateObj ($oIE, 0, 0, 1024, 768) GUISetState (@SW_SHOW) _IENavigate ($oIE, "http://www.dobeash.com/test.html") $oT = _IEGetObjById ($oIE, 'fileExample') MouseMove (_IEPropertyGet ($oT, "screenx") + _IEPropertyGet ($oT, "width") - 10, _IEPropertyGet ($oT, "screeny") + _IEPropertyGet ($oT, "height") / 2) MouseClick ("left") WinWait ("Choose File to Upload") $hChoose = WinGetHandle ("Choose File to Upload") ControlSetText ($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") ControlClick ($hChoose, "", "Button2") Link to comment Share on other sites More sharing options...
DaleHohm Posted December 10, 2009 Share Posted December 10, 2009 With a quick test, it does not appear that the example fails on "real" websites, but rather it fails when used embedded in an IE GUI. The following code works fine: #include <IE.au3> #AutoIt3Wrapper_Run_Debug_Mode=Y $oIE = _IECreate("http://www.dobeash.com/test.html") $oT = _IEGetObjById ($oIE, 'fileExample') MouseMove (_IEPropertyGet ($oT, "screenx") + _IEPropertyGet ($oT, "width") - 10, _IEPropertyGet ($oT, "screeny") + _IEPropertyGet ($oT, "height") / 2) MouseClick ("left") WinWait ("Choose File to Upload") $hChoose = WinGetHandle ("Choose File to Upload") ControlSetText ($hChoose, "", "Edit1", "C:\AUTOEXEC.BAT") Sleep(4000) ControlClick ($hChoose, "", "Button2") I suggest that if you use the technique here http://www.autoitscript.com/forum/index.php?showtopic=99234&st=0&p=712594&hl=_WinAPI_SetWindowLong&fromsearch=1&#entry712594 instead of _IECreateEmbedded you'll be fine. 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 More sharing options...
pickypiglet Posted May 13, 2012 Share Posted May 13, 2012 Hi Guys, Any final resolution to this post? It was posted in 2009. So hopefully there has been some work in this area. I was having the same problem: But was able to resolve with the help of this thread since I'm using very old IE. $o_form = _IEFormGetObjByName($oIE, "Form") $oUpload = _IEGetObjByName($o_form, "file1") _IEAction($oUpload, "focus") Send("{SPACE}") Sleep(5000) Send("C:\test.csv") Thx. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now