Jump to content
Sign in to follow this  
Seminko

[SOLVED*] IE Set value in an input without a form tag

Recommended Posts

Seminko

Hey,

i would like to set a value into an INPUT field.

Checked the _IEFormElementSetValue function but that does require _IEFormGetObjByName and this is where the problem comes in. The input field I want to write to is not a part of a form tag. It is part of a table.

<input type="text" class="w2" id="nabidka_vozidel_formular_tach_od" name="nabidka_vozidel_formular_tach_od" onchange="GLOBAL.pocetInzerceNZ(&quot;nabidka_vozidel_formular&quot;,&quot;tach_od&quot;,&quot;&quot;);" autocomplete="off">

I tried this but that didn't work:

$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
_IEFormElementSetValue($oDownloadSamples, "123")

If you want to try the site I'm working with is https://www.tipcars.cz/. There is a menu on the top left hand side and if you click the "vyhledat" button the input fields will show up.

Thanks

Edited by Seminko

Share this post


Link to post
Share on other sites
SmOke_N

Look at _IEPropertySet outertext


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Seminko
1 hour ago, SmOke_N said:

Look at _IEPropertySet outertext

Error from function _IEPropertySet, $_IESTATUS_InvalidObjectType which is strange since <input type="text"

 

Strange, tried that again and no error appeared but the text wasn't written either.

Here's the code

#include <IE.au3>
#include <INet.au3>

$url = "https://www.tipcars.com/"
$oIE = _IECreate($url)
_IELoadWait($oIE)

$SearchButton = _IEGetObjById($oIE,"homepage_vyhl_frm_vyhledej")
_IEAction($SearchButton, "click")
_IELoadWait($oIE)
; INCORRECT: $oDownloadSamples = _IEGetObjById($oIE, "homepage_vyhl_frm_rok_od")
$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
_IEPropertySet($oDownloadSamples, "outertext", "123")

 

Edited by Seminko

Share this post


Link to post
Share on other sites
Seminko

Strange, _IEAction($oDownloadSamples, "focus") doesn't work either. HELP!

Share this post


Link to post
Share on other sites
Danp2
37 minutes ago, Seminko said:

$oDownloadSamples = _IEGetObjById($oIE, "homepage_vyhl_frm_rok_od")

Are you sure that this is the correct element? When I look at the source, this appears to be a Select element, not an input element.

Share this post


Link to post
Share on other sites
Seminko
11 minutes ago, Danp2 said:

Are you sure that this is the correct element? When I look at the source, this appears to be a Select element, not an input element.

The code is "wrong", i used different input field. Let's stick with "nabidka_vozidel_formular_tach_od" from the original post.

#include <IE.au3>
#include <INet.au3>

$url = "https://www.tipcars.com/"
$oIE = _IECreate($url)
_IELoadWait($oIE)

$SearchButton = _IEGetObjById($oIE,"homepage_vyhl_frm_vyhledej")
_IEAction($SearchButton, "click")
_IELoadWait($oIE)
$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
_IEPropertySet($oDownloadSamples, "outertext", "123")

 

Edited by Seminko

Share this post


Link to post
Share on other sites
Danp2
22 minutes ago, Seminko said:

The code is "wrong", i used different input field. Let's stick with "nabidka_vozidel_formular_tach_od":

Sorry, but that doesn't make sense to me. If you are switching target elements where the element type is different (input vs select), then why would you expect the method to update the element to remain the same?

Share this post


Link to post
Share on other sites
Seminko
1 minute ago, Danp2 said:

Sorry, but that doesn't make sense to me. If you are switching target elements where the element type is different (input vs select), then why would you expect the method to update the element to remain the same?

Disregard "homepage_vyhl_frm_rok_od". That was a missclick. I copied part of my previous code where I actually wanted to control a select element.

However, "nabidka_vozidel_formular_tach_od" is not a select element or at least not that I can see. It says Input type="Text". And this is what I neet to put numbers in.

Share this post


Link to post
Share on other sites
Danp2

It appears to work after adding in a Sleep command to allow the page to fully load --

#include <IE.au3>
#include <INet.au3>

$url = "https://www.tipcars.com/"
$oIE = _IECreate($url)
_IELoadWait($oIE)

$SearchButton = _IEGetObjById($oIE,"homepage_vyhl_frm_vyhledej")
_IEAction($SearchButton, "click")
_IELoadWait($oIE)

sleep(2000)

$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
_IEFormElementSetValue($oDownloadSamples, "123")

 

  • Like 1

Share this post


Link to post
Share on other sites
Seminko
14 minutes ago, Danp2 said:

It appears to work after adding in a Sleep command to allow the page to fully load --

I was just writing a comment about the possibility of the site not being properly loaded despite _IELoadWait($oIE) when you replied  :). I tried _IEFormElementSetValue right in the beginning but it didn't work so I assumed it's not the correct function.

It works now! Thanks!

I have no idea but I assume _IELoadWait($oIE) doesn't work because the site is not loading per se but a script is being started. Do we know of any other method other than _IELoadWait($oIE) that would wait for it to properly finish? I would like to avoid hardcoding a Sleep function.

 

Well this works, but the issue is that if the site changes the IDs this will loop indefinitely.

#include <IE.au3>
#include <INet.au3>

$url = "https://www.tipcars.com/"
$oIE = _IECreate($url)
_IELoadWait($oIE)

$SearchButton = _IEGetObjById($oIE,"homepage_vyhl_frm_vyhledej")
_IEAction($SearchButton, "click")
_IELoadWait($oIE)

$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
While @error
    Sleep(100)
    $oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od")
WEnd

_IELoadWait($oDownloadSamples)

_IEFormElementSetValue($oDownloadSamples, "123")

$oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_do")
_IEFormElementSetValue($oDownloadSamples, "321")

 

Edited by Seminko

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

    • Seminko
      By Seminko
      Wrote a script that grabs all of the IP addresses from Netflix's IP log, checks the IPs and returns suspicious activity.
      Everything works as it should but only when _IECreate is set to visible. When visible is set to false, it fails to login for some reason.
      Any ideas what might cause it and/or how to circumvent that?
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • hemichallenger
      By hemichallenger
      Hello,
      If anyone can help, it would be greatly appreciated. The code is just an example and similar to the issue with an internal webpage. I'm trying to autofill than click the submit button. I get the same error running the script.
      _IEFormElementSetValue, $_IESTATUS_InvalidObjectType
      IEGetObjById, $_IESTATUS_NoMatch
      Is it possible to edit the <textarea></textarea>  field with AutoIt?  If anyone could assist me on how. Than I could have a better understanding and chance in figuring it out on my main script. Thank you
      #include <IE.au3> Local $oIE1 = _IECreate ("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea") _IELoadWait($oIE1) local $oFormCollection = _IEFormGetCollection($oIE1,0) local $oid = _IEGetObjByid($oFormCollection, "iframeResult") _IEFormElementSetValue($oid, "test") sleep (2000) Local $oIE2 = _IECreate ("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_scripts_intro") _IELoadWait($oIE2) $oForm2 = _IEFormGetCollection($oIE2,0) $oClickMe = _IEGetObjById($oForm2, "demo") _IEAction($oClickMe, "focus") _IEAction($oClickMe, "click")
    • Blueman
      By Blueman
      Hey Guys,
      Hope that you can help me with something, maybe this is a bug in the new version of AUTOIT but first i will check it with you to know for sure.
      I have made a simple GUI with a Embedded IE Object, then i would like to read the HTML with _IEBodyReadHTML(), easy right?
      When i use the old IE.au3 include from a year back or so, it is working fine!
      When i use the new IE.au3 include came with the new installation that is currently available on autoitscript.com it isnt working (i get a result that says; 0).
      Let me show you.
       
      Working Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE_PreVersion.au3> ;Older Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      Failing Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE.au3> ;New Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      I have attachted all files and i am testing on Windows 10 with the latest SciTe Program (Not compiled). 
      When i compile the script it is showing the same result.
      Thanks guys!
      IE_PreVersion.au3
      IE.au3
      IE_EmbeddedVersioning.au3
    • Lisuter
      By Lisuter
      Hello...

      How i can write data from txt to +3 Input?
      Example:
      In txt i have:
      Michael XYZ, 21, Boston
      Olex Marshal, 17, Boston
      Alex XYZ, 19, Boston
       
      And now i want load that data to input in autoit. 

      Name          y.o          city
      [ Input1]  [Input2] [Input3]
      [ Input4]  [Input5] [Input6]
      [ Input7]  [Input8] [Input9]
       
      After load should be:
      Name               y.o            city
      [Michael XYZ]      [21]     [Boston]
      [ Olex Marshal]  [17]      [Boston]
      [ Alex XYZ]           [19]      [Boston]
       
      FileOpen("Test.txt",0)                          $aas = GUICtrlSetData($Input1, FileReadLine("Test.txt",1))             FileClose("Test.txt") But its wrong. ofcourse its load all to input 1. So now how do you load this data directly into each input separately? The comma stop sign is here. Each line is a new person
×