Jump to content
Sign in to follow this  
sathish

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

Share this post


Link to post
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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
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

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  

  • Similar Content

    • By Seminko
      Hey there,
      below function returns an "object collection" (not sure if that's the correct term) of 'a' elements grabbed from within //*[@id="J_DetailMeta"].
      However, I need the returned collection not to include objects with 'aria-disabled = true'. Is there a way of removing specific objects from such a collection?
      Func GetObjectList($sPicker) $oDetailMeta = _IEGetObjById($oIE, "J_DetailMeta") If Not @error Then $tags = $oDetailMeta.GetElementsByTagName("ul") For $tag in $tags $data_ID_value = $tag.GetAttribute("data-property") If $sPicker = "color" Then If $data_ID_value = '????' Or $data_ID_value = "????" Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "network" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "storage" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf EndIf Next EndIf Return $oReturnList EndFunc $oColorList = GetObjectList("color") For $oColor In $oColorList If StringInStr($oColor.GetAttribute("aria-disabled"), "true") <= 0 Then ; remove object from the collection ??? EndIf Next  
    • By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
    • By MakzNovice
      Hello Experts,
      I am working on modifying table data of a browser currently in IE (soon in FF)
      My sequence of operations:
      1. Activate Browser
      2. Get Browser table
      3. Modify data  in table
      4. Suppress any warning/error message from webpage
      5. Activate the Webpage again 
      6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5})
       
      My problem is at Step 5, as it activates the wrong window ( last used application rather than my browser window)
      My code snippet for it as follows
      $bFoundWindow = False Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") Local $hWND = 0 For $i = 1 To $aList[0][0] If False = $bFoundWindow And $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 1) Then WinActivate($aList[$i][1]) ; 1. Activate Browser window WinSetState ( $aList[$i][1], "", @SW_MAXIMIZE) $hWND = $aList[$i][1] $objEditIE = _IEAttach ($aList[$i][1], "hwnd") $oTitles = _IETagNameGetCollection($objEditIE, "TITLE") For $oTitle In $oTitles $sTitle = $oTitle.innerText If $sTitle = $searchString Then MsgBox(0,"APPLICATION Found", "Got Edit List Window", 1) $bFoundWindow = True ExitLoop EndIf Next EndIf Next If False = $bFoundWindow Then MsgBox(0,"Error","Please launch Edit window for updating values in Browser prior to script execution",10) Exit EndIf ; MY CODE HERE TO MODIFY TABLE ; 2. Get Browser table ; 3. Modify data  in table ; Check if message from webpage pop-up window exists if so click ok on it Local $nCounter = 0 Local $nMaxCounter = 5 while 1 If WinExists("Message from webpage","") Then ControlClick("Message from webpage","","Button1","primary",1) ;4. Suppress any warning/error message from webpage Else $nCounter = $nCounter + 1 Sleep(100) ;MsgBox(0,"Counter", $nCounter, 1) If $nCounter = $nMaxCounter Then ExitLoop EndIf WEnd ;5. Activate the Webpage again  WinActivate($hWND) ; have already tried WinActivate($aList[$i][1]) but no success ;6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5}) Send("{F11}") WinActivate($hWND) ;WinActivate($aList[$i][1]) Sleep(100) Send("{F11}") Any support will be highly appreciated
×
×
  • Create New...