Skull117 Posted July 22, 2018 Share Posted July 22, 2018 Hello, I'm a beginner with autoit. I create a script with function _IECreate for populate a webpage. There is a inputbox that needs to be clicked for select the image to upload. The Windows frame for upload opens but the script stops at _IEActicon($object, "click"). When i close the Windows frame the script run and write the text in the wrong page. If i write a winWaitActivate after IEAction the script stop but if i close the frame and click manually on the inputbox with the mouse the script run. I think the problem is IEAction Test script: $urlAdd = _IEAttach("https://www2.mio.it", "title") _IELoadWait($urlAdd,5000) _IEAction(_IEFormElementGetObjByName($form1, "fileElem"), "click") caricaFoto() Func caricaFoto() ;waitFocus("Selezionare il file da caricare") For $i=1 to 5 Send("{TAB}") Next Send("{ENTER}") Send(@DesktopDir & "\annunci\") Send("{ENTER}") For $i=1 to 5 Send("{TAB}") Next Send("ktm.jpg") Send("{ENTER}") EndFunc html input text: <input name="fileElem" id="fileElem" style="visibility: hidden; position: absolute;" onchange="handleFiles(this.files)" type="file" accept="image/*" multiple=""> Thank you Link to comment Share on other sites More sharing options...
Danp2 Posted July 22, 2018 Share Posted July 22, 2018 Hi, This is a common problem. Look at the 2nd example for _IEAction in the help file. Also, search the forum for the alternative solutions, such as -- Regards, Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Skull117 Posted July 22, 2018 Author Share Posted July 22, 2018 Thanks for the answer I already tried to look at the documentation of the IEAction and I tried in various ways, but the problem persists. I watch the exmple 2 and try this: Local $hwnd = _IEPropertyGet($urlAdd, "hwnd") _IEAction(_IEFormElementGetObjByName($form1, "fileElem"), "click") WinWait("Selezionare il file da caricare", "") ControlClick("Selezionare il file da caricare", "", "[CLASS:Button; TEXT:Apri; Instance:1;]") _IELoadWait($urlAdd) caricaFoto() But dont work because the _IEAction freeze the script, if i close the frame the script run. Link to comment Share on other sites More sharing options...
Danp2 Posted July 22, 2018 Share Posted July 22, 2018 You missed the point of Ex 2. Instead of performing the click with _IEAction, it sets focus to the element and then uses Controlsend to trigger the button. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Skull117 Posted July 23, 2018 Author Share Posted July 23, 2018 (edited) I can't understand ... unfortunately the documentation of this language is only in English. I try this but stop at winWait Local $hwnd = _IEPropertyGet($urlAdd, "hwnd") _IEAction(_IEFormElementGetObjByName($form1, "fileElem"), "focus") ControlClick($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1;]") WinWait("Selezionare il file da caricare", "") ControlClick("Selezionare il file da caricare", "", "[CLASS:Button; TEXT:Apri; Instance:1;]") _IELoadWait($urlAdd) caricaFoto() Edited July 23, 2018 by Skull117 Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2018 Share Posted July 23, 2018 Your first ControlClick should be a ControlSend instead -- ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1;]", "{Enter}") 50 minutes ago, Skull117 said: unfortunately the documentation of this language is only in English Have you tried using Google to translate into your native language? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Skull117 Posted July 23, 2018 Author Share Posted July 23, 2018 I tried to send with controlSend enter but need one click on inputbox to open the window Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2018 Share Posted July 23, 2018 Have you run the code from Ex 2, so that you have a better understanding of how this is supposed to work with the ControlSend? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Juvigy Posted July 24, 2018 Share Posted July 24, 2018 You need something like this t put before your click. _ExecuteInBackground _IEAction($oDiv,"click") Func _ExecuteInBackground() Local $sCommand = _ 'Local ' & _ '$Dummy1 = WinWaitActive("Choose File to Upload", "", 20), ' & _ '$Dummy2 = Sleep(1000), ' & _ '$Dummy3 = ControlSetText("Choose File to Upload", "", "Edit1", "C:\Path\To\File.doc;C:\Path\To\File1.doc"), ' & _ '$Dummy4 = ControlClick("Choose File to Upload", "", "Button1") ' & _ '' $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' ConsoleWrite($sCommand & @CRLF) Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand) EndFunc ;==>_ExecuteInBackground Skull117 1 Link to comment Share on other sites More sharing options...
Skull117 Posted July 24, 2018 Author Share Posted July 24, 2018 Juvigy thanks for help i solved used 2 different script but in a differente way because the _IEAction stopped the script and the example for _IEAction dont work in this case. I try this and work script 1: Run(@DesktopDir & "\inputFile.exe") _IEAction($file = _IEFormElementGetObjByName($form1, "fileElem"), "click") script 2: WinWait("Selezionare il file da caricare") WinActivate("Selezionare il file da caricare") For $i=1 to 5 Send("{TAB}") Next Send("{ENTER}") Send(@DesktopDir & "\annunci\") Send("{ENTER}") For $i=1 to 5 Send("{TAB}") Next Send("ktm.jpg") Send("{ENTER}") Your method for starting the second script is interesting, can you explain how it works? Im a newbie with autoit and i wont to learn Link to comment Share on other sites More sharing options...
Juvigy Posted July 25, 2018 Share Posted July 25, 2018 Before the Actionclick it starts another chunk of autoit code which basically waits for the IEaction and then clicks on the popup and thus solves the issue. That way you dont have to rely on external exe file for that, but basically it is the same thing. 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