Jump to content

_IEAction($n,"click") script freeze


Recommended Posts

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

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

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 by Skull117
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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

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...