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

    • SkysLastChance
      By SkysLastChance
      I am trying to wait for a pop up in IE with the title of "filed". I believe it is in a IE-frame.  I am not having any luck attaching to it. The best thing I have been able to do is find the title using the below code. 
      Is there a way I can just make AutoIt wait until it finds the  "Filed" value from the below code?
      Thank you for any help, I am probably making this harder then it really is. 
      $oIE = _IEAttach("Meditech") $oInputs1 = _IETagNameGetCollection($oIE, "div") For $oInput1 in $oInputs1 If StringStripWS($oInput1.innertext,1) = "Filed" Then $target = $oInput1 ExitLoop Else $target = "NOT FOUND" EndIf Next I have tried different variations of
      _IEAttach("MEDITECH","Filed") WinWaitActive("MEDITECH", "Filed") Here is what the popup looks like.

    • levila
      By levila
      hi guys, how can i autoit IE open the downloaded item when message box pop up show class name DirectUIHWND1
      i get some codding from another source to auto cancel, but cant get idea how to get position to other option
      Do Sleep(1000) Until WinActive("[Class:IEFrame]") While WinActive("[Class:IEFrame]") Local $hIE = WinGetHandle("[Class:IEFrame]") Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]") Local $aPos = ControlGetPos($hIE, "", $hCtrl) Local $aWinPos = WinGetPos($hIE) If ControlCommand($hIE, "", $hCtrl, "IsVisible") And $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page. ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 70, $aPos[3] - 30) Sleep(500) ControlSend($hIE, "", $hCtrl, "{enter}") EndIf ExitLoop WEnd hope this can help, 
    • XaelloNegative
      By XaelloNegative
      Hi,
      So, I am trying to automate and simplify the retrieval of data from our company website (made by an outside company). I've had experience with IE manipulation via autoIt however, this one is a bit tricky for me.
      I have a table that has 81 cells which are buttons. What im trying to get is the information in "data-content" tag. 
      <a id="bookedVehicleLinkButton" class="btn btn-sm btn-block btn-xsm btn-success" data-toggle="popover" data-placement="bottom" data-original-title="Trip Details" data-container="body" data-content="Plate No: UGQ-857<br />Model: TOYOTA GRANDIA GL" href="javascript:__doPostBack('ctl00$ctl00$masterContentPlaceholder$reservationContentPlaceholder$bookingDataList$ctl00$vehicleDataList$ctl28$bookedVehicleLinkButton','')">IXARA (LITO SULIT)</a> Tried using the following:
      $oTagsCell = _IETagNameGetCollection($oIE, "td") For $item in $oTagsCell $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next $oTagsTable = _IETagNameGetCollection($oIE, "table") For $item in $oTagsTable $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next $oTagsLink = _IETagNameGetCollection($oIE, "a") For $item in $oTagsLink $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next I don't receive any errors from my aforementioned attempts however no luck in getting those "data-contents". Attached is a screenshot, I do the looking of elements in chrome but the codes are for IE. And if you might ask, the cells (or buttons) have the same ID.
       
      Thank you guys for any inputs.
       
    • Blueman
      By Blueman
      Hey Guys,
      Maybe you can help me with something small.
      It is not terrible but it slows down my script and after a while even crash the script.

      First i explain what i have;
      I have a GUI with a lot of GUICtrlCreateInput controls, lets say 600 pieces.
      All the controls are hidden when the GUI is displayed, i have 3 buttons attached to 200 pieces each.
      When i press button-1 the first 200 controls are showed,
      When i press button-2 the first 200 controls are hidden and the next 200 controls are showed,
      etc, etc.
      This is working perfectly but after a while the GUI is getting slower and slower.
      After a while the controls aren't responding anymore and the script crashes.
      When i compile the script to 64-Bits version the speed is a lot better but you can still see the script slowing down each time i use the buttons.
      I think there has to be a buffer somewhere that is filling each time i show and hide the controls, but how can i clear that buffer without restarting the script?
      Deleting and re-creating the controls didn't help, deleting the entire gui (and controls) and re-creating it didn't help also.
      The only thing that is working is restarting the script.

      Thanks guys!

      PS: If you need a working example i can add it to this topic, just let me know. It is not rocket science, i just create the controls and show/hide them with a while loop and 3 buttons.
       
    • XinYoung
      By XinYoung
      Quick question: How can I click this "Select All" button in IE? There's no ID, and the href is "#"  
      Am I looking at the wrong html code?
      Am I looking
      Thank you all in advance!
×