Jump to content

Recommended Posts

I created a script that autocomplete a form but it doesn't work and I don't know why. Could you help me? Thank you

 

HTML code:

<form action="adauga_comentariu.php" method="POST">
            Nume:<input type="text" required name="nume_utilizator" id="nume"><br><br>
            Email:<input type="email" required name="adresa_email" id="email"><br><br>
            Comentariu:<br>
            <textarea name="comentariu" cols="45" id="comentariu"></textarea><br><br>
            <input type="hidden" name="id_model" value="<?=$id_model?>">
            <center><input type="submit" id="adauga" value="Adaugă" style="width: 100px; height: 30px; font-size: 16px;"></center>
        </form>

 

AutoIT code:

#include <IE.au3>

Local $mag = _IECreate("http://localhost/mag/model.php?id_model=8")
Sleep(2000)

Local $nume= _IEGetObjById($mag,"nume")
Local $email= _IEGetObjById($mag,"email")
Local $comentariu= _IEGetObjById($mag,"comentariu")

_IEFormElementSetValue ($nume,"Test")
_IEFormElementSetValue ($email,"test@test.com")
_IEFormElementSetValue ($comentariu,"Test Test Test Test Test")

 

AutoIT errors:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Andrei\Desktop\emag.ro.au3"    
--> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023179, Browser has been deleted prior to operation.)
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType

Link to post
Share on other sites

For me is working right.

#include <IE.au3>

Local $mag = _IECreate("")


Local $sHTML = ""
$sHTML &= '<form action="adauga_comentariu.php" method="POST">' & @CRLF
$sHTML &= 'Nume:<input type="text" required name="nume_utilizator" id="nume"><br><br>' & @CRLF
$sHTML &= 'Email:<input type="email" required name="adresa_email" id="email"><br><br>'& @CRLF
$sHTML &= 'Comentariu:<br>' & @CRLF
$sHTML &= '<textarea name="comentariu" cols="45" id="comentariu"></textarea><br><br>' & @CRLF
$sHTML &= '<input type="hidden" name="id_model" value="<?=$id_model?>">' & @CRLF
$sHTML &= '<center><input type="submit" id="adauga" value="Adauga" style="width: 100px; height: 30px; font-size: 16px;"></center>' & @CRLF
$sHTML &= ' </form>' & @CRLF



_IEDocWriteHTML($mag, $sHTML)


Local $nume= _IEGetObjById($mag,"nume")
Local $email= _IEGetObjById($mag,"email")
Local $comentariu= _IEGetObjById($mag,"comentariu")

_IEFormElementSetValue ($nume,"Test")
_IEFormElementSetValue ($email,"test@test.com")
_IEFormElementSetValue ($comentariu,"Test Test Test Test Test")

Saludos

Link to post
Share on other sites

Is the local web server up and running?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

For me is working right.

#include <IE.au3>

Local $mag = _IECreate("")


Local $sHTML = ""
$sHTML &= '<form action="adauga_comentariu.php" method="POST">' & @CRLF
$sHTML &= 'Nume:<input type="text" required name="nume_utilizator" id="nume"><br><br>' & @CRLF
$sHTML &= 'Email:<input type="email" required name="adresa_email" id="email"><br><br>'& @CRLF
$sHTML &= 'Comentariu:<br>' & @CRLF
$sHTML &= '<textarea name="comentariu" cols="45" id="comentariu"></textarea><br><br>' & @CRLF
$sHTML &= '<input type="hidden" name="id_model" value="<?=$id_model?>">' & @CRLF
$sHTML &= '<center><input type="submit" id="adauga" value="Adauga" style="width: 100px; height: 30px; font-size: 16px;"></center>' & @CRLF
$sHTML &= ' </form>' & @CRLF



_IEDocWriteHTML($mag, $sHTML)


Local $nume= _IEGetObjById($mag,"nume")
Local $email= _IEGetObjById($mag,"email")
Local $comentariu= _IEGetObjById($mag,"comentariu")

_IEFormElementSetValue ($nume,"Test")
_IEFormElementSetValue ($email,"test@test.com")
_IEFormElementSetValue ($comentariu,"Test Test Test Test Test")

Saludos

For me isn't working this code

Link to post
Share on other sites

 Does code I posted work for you?

What console output do you get running my code?

Saludos

Link to post
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Andrei\Desktop\test.au3"    
--> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023179, Browser has been deleted prior to operation.)
--> IE.au3 T3.0-2 Error from function _IEDocWriteHTML, $_IESTATUS_InvalidObjectType (Expected document element)
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
--> IE.au3 T3.0-2 Error from function _IEGetObById, $_IESTATUS_InvalidObjectType
--> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType
>Exit code: 0    Time: 0.9284

 

Link to post
Share on other sites

this is the code

#include <IE.au3>

Local $mag = _IECreate("http://localhost/mag/model.php?id_model=8")


Local $sHTML = ""
$sHTML &= '<form action="adauga_comentariu.php" method="POST">' & @CRLF
$sHTML &= 'Nume:<input type="text" required name="nume_utilizator" id="nume"><br><br>' & @CRLF
$sHTML &= 'Email:<input type="email" required name="adresa_email" id="email"><br><br>'& @CRLF
$sHTML &= 'Comentariu:<br>' & @CRLF
$sHTML &= '<textarea name="comentariu" cols="45" id="comentariu"></textarea><br><br>' & @CRLF
$sHTML &= '<input type="hidden" name="id_model" value="<?=$id_model?>">' & @CRLF
$sHTML &= '<center><input type="submit" id="adauga" value="Adauga" style="width: 100px; height: 30px; font-size: 16px;"></center>' & @CRLF
$sHTML &= ' </form>' & @CRLF



_IEDocWriteHTML($mag, $sHTML)


Local $nume= _IEGetObjById($mag,"nume")
Local $email= _IEGetObjById($mag,"email")
Local $comentariu= _IEGetObjById($mag,"comentariu")

_IEFormElementSetValue ($nume,"Test")
_IEFormElementSetValue ($email,"test@test.com")
_IEFormElementSetValue ($comentariu,"Test Test Test Test Test")

 

Link to post
Share on other sites

It look like your server is not working.

try the code I posted with _IECreate("") Instead _IECreate("http://localhost/mag/model.php?id_model=8")

 

Saludos

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...