Jump to content

<input type=file> problem, why script pauses in IE.au3


Recommended Posts

Hello Forum,

I tried to fill up a form which has the button <input type="file">,

I got success in clicking the browse button, but after that the script pauses, can't able to send any commands to the browser, why is it so, is there any security restrictions by IE, how to solve this, please help,

Below is my Code

#RequireAdmin
;$btype = $CmdLine[1]
;$filepath = $CmdLine[2]
;$pass = $CmdLine[3]


$btype = "Automobile Dealers"
$filepath="D:\Datas\Coimbatore_Automobile-Dealers_Data.xml"
$pass="avssoft"
$weburl="http://jrvindia.com/newdata.php"

#include <IE.au3>


$oIE = _IECreate($weburl)


_IELoadWait($oIE)

$sText1 = _IEBodyReadHTML ($oIE)

If StringInStr($sText1,"JRV INDIA Data Upload Panel") Then
$oform = _IEFormGetObjByName($oIE, "form1")
$obtype = _IEFormElementGetObjByName($oform, "database")
$oupload = _IEFormElementGetObjByName($oform, "uploadfile")
$opassword = _IEFormElementGetObjByName($oform, "secpass")

;_IEFormElementSetValue($obtype, $btype)
_IEFormElementSetValue($opassword, $pass)
$oSelect = _IEFormElementGetObjByName($oForm, "database")
_IEFormElementOptionselect($oSelect, $btype, 1, "byText")


;$oInputFile = _IEFormElementGetObjByName($oForm, "uploadfile")

$oElement = _IEFormElementGetObjByName($oForm, "uploadfile")
$oElement.fireEvent("onmouseover")
$oInput = _IETagnameGetCollection($oForm, "input", 0)
_IEAction($oInput, "click")
exit


;$Button = _IEGetObjByName ($oIE, "upload")
;_IEAction ( $Button, "click" )
;_IELoadWait($oIE)
Endif

HTML Code

<h1 align="center">JRV INDIA Data Upload Panel</h1>
<div align="center"> <form action="newdata.php" method="post" enctype="multipart/form-data" name="form1">
<table align="center">
<tr>
     <td colspan="2"><div align="center"><strong>Uplad New Data</strong></div></td>
</tr>
<tr><td>

<p>
     <label for="select"></label>
     Select The Database
     </p>
</td>
     <p>
         <label for="fileField"></label>
     </p></td>
</tr>
<tr>
     <td>Select The XML File</td>
     <td><input type="file" name="uploadfile" id="uploadfile" /></td>
</tr>
<tr>
     <td>Enter Your Password</td>
     <td>
     <label for="secpass"></label>
     <input type="password" name="secpass" id="secpass" />
     </td>
</tr>
<tr>
     <td>&nbsp;</td>
     <td><input type="submit" name="upload" id="upload" value="Upload File" /></td>
</tr>
<tr>
     <td colspan="2">&nbsp;</td>
</tr>
<tr>
     <td colspan="2">&nbsp;</td>
</tr>
</table></form>
</div>
<p align="center">Developed by <a href="http://www.avssoftwares.in">AVS WEBRAMS INFOTECH</a></p>

Thanks & Regards

Sathish V.

Link to comment
Share on other sites

Your script misses some kind of error checking. Every function sets the return value, @error and @extended. Check this for an error after each function call and then decide if the script should continue.

The IE functions provide good info in the output pane of SciTE too.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Your script misses some kind of error checking. Every function sets the return value, @error and @extended. Check this for an error after each function call and then decide if the script should continue.

The IE functions provide good info in the output pane of SciTE too.

Thanks for your reply, but the problem is the restrictions applied by IE it seems, is there any way to overcome it, all lines of my code works fine, the problem is it pauses the script after the click of Browse button, Is there any solution for that

Link to comment
Share on other sites

Anyway, thanks forum, i found out a solution finally,

Here is the updated code

#RequireAdmin
;$btype = $CmdLine[1]
;$filepath = $CmdLine[2]
;$pass = $CmdLine[3]


$btype = "Automobile Dealers"
$filepath="D:\Datas\Coimbatore_Automobile-Dealers_Data.xml"
$pass="avssoft"
$weburl="[url="http://jrvindia.com/newdata.php"]http://jrvindia.com/newdata.php"[/url]

#include <IE.au3>


$oIE = _IECreate($weburl)


_IELoadWait($oIE)

$sText1 = _IEBodyReadHTML ($oIE)

If StringInStr($sText1,"JRV INDIA Data Upload Panel") Then
    $oform = _IEFormGetObjByName($oIE, "form1")
    $obtype = _IEFormElementGetObjByName($oform, "database")
    $oupload = _IEFormElementGetObjByName($oform, "uploadfile")
    $opassword = _IEFormElementGetObjByName($oform, "secpass")
    
    ;_IEFormElementSetValue($obtype, $btype)
    _IEFormElementSetValue($opassword, $pass)
    $oSelect = _IEFormElementGetObjByName($oForm, "database")
    _IEFormElementOptionselect($oSelect, $btype, 1, "byText")
    
    


    $oT = _IEFormElementGetObjByName($oForm, "uploadfile")
    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", $filepath)
    Sleep(4000)
    ControlClick ($hChoose, "", "Button2")


    $Button = _IEGetObjByName ($oIE, "upload")
    _IEAction ( $Button, "click" )
    _IELoadWait($oIE)
    


Endif

Thank you All,

Sathish V.

Edited by sathish
Link to comment
Share on other sites

  • 2 years later...

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

×
×
  • Create New...