Recommended Posts

Omnitica 0

Omnitica 0

I'm new to the forums! Couldn't find any threads covering this issue. Sorry if I'm wrong.

I'm having problems changing the text/value of a input box. The particular box doesn't have a name or id, just: class="jq_hotkeys_enabled form-control".
This class appears multiple times throughout the source, so I don't think It's right to reference that object. See image 1.

However, I've managed to find a object with the name "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper" which contains the value of the input box, and the id for the person in the dropdown/combobox left of it. (with "dummy-1" selected).See image 2.

The box gets its new value after the page reloads by the theForm.submit() function.
This is a bit unfortunate as I want the changes to happen instantly like when I type in the box with the keyboard... or select in the combobox.

Maybe someone knows how I can do this? Looking forward to an answer!
Thanks in advance.

Note: Unfortunately I can't provide with the real URL as it is constricted to employees in the company I work for, but let me know If I should provide anything else.

Share this post

Link to post

Share on other sites

Danp2 247

Danp2 247

The site is likely using a Javscript framework, such as Node.js or React. These will obscure the code, use hidden objects, etc like you are seeing. This is probably going to be difficult for us to assist you with since the site is private.

Share this post

Link to post

Share on other sites

Omnitica 0

Omnitica 0

The site is likely using a Javscript framework, such as Node.js or React. These will obscure the code, use hidden objects, etc like you are seeing. This is probably going to be difficult for us to assist you with since the site is private.

Share this post

Link to post

Share on other sites

Danp2 247

Danp2 247

This (possible) solution came from this prior discussion. I'm unable to get this page to render properly in IE. Therefore, I'm unable to test the following code and you will likely need to adjust or adapt it to fit your actual environment --

#include <ie.au3>Local$oIE=_IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded")Local$oDocument=_IEDocGetObj($oIE)Local$oWindow=$oDocument.ParentWindow$oWindow.setTimeout("document.body.JSeval = eval; ",0); a reference to the eval methodSleep(2000); give a little time to the browser to create above variables within the javascript environment.$JSeval=$oIE.Document.body.JSeval; a reference to the eval javascript method from within AutoIt$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)")[0] = 10')$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)").change()')

Share this post

Link to post

Share on other sites

Omnitica 0

Omnitica 0

This (possible) solution came from this prior discussion. I'm unable to get this page to render properly in IE. Therefore, I'm unable to test the following code and you will likely need to adjust or adapt it to fit your actual environment --

#include <ie.au3>Local$oIE=_IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded")Local$oDocument=_IEDocGetObj($oIE)Local$oWindow=$oDocument.ParentWindow$oWindow.setTimeout("document.body.JSeval = eval; ",0); a reference to the eval methodSleep(2000); give a little time to the browser to create above variables within the javascript environment.$JSeval=$oIE.Document.body.JSeval; a reference to the eval javascript method from within AutoIt$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)")[0] = 10')$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)").change()')

Hey, thank you for your help. Again, much appreciated.

I'm guessing I need to add Local $oDocument = _IEDocGetObj($oIE) to get a reference.

I'm having trouble understanding the java functions:

$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)")[0] = 10')
is this the function that sets the value of the box?

$JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)").change()')
And this is the function that trigger the change?

Share this post

Link to post

Share on other sites

Danp2 247

Danp2 247

Yes, the first call sets the value of the input element. This could also be done with _IEFormElementSetValue if you can get a reference to the element. The second call triggers the change event for all matching elements.

Share this post

Link to post

Share on other sites

Omnitica 0

Omnitica 0

Yes, the first call sets the value of the input element. This could also be done with _IEFormElementSetValue if you can get a reference to the element. The second call triggers the change event for all matching elements.

Did you try running the code as posted? If so, what was the outcome?

I tried running the script, but no success . The value doesn't change. However I'm curious if the $JSeval('$(".input-group .form-control:not(:first-child):not(:last-child)")[0] = 10')
refers to the actual input box. As there are many boxes with the same class. Maybe I'm wrong.

But now I'm looking for a way to change the option in the combobox, which is defined by value="4448,6767"> (4448)4448 is the id of a user.

I just used _IEFormElementSetValue on the ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper.
And set the value to "4448,6767" But then I need to reload the page for the changes to happen.

Share this post

Link to post

Share on other sites

Danp2 247

Danp2 247

#include <ie.au3>Local$oIE=_IEAttach("UR-000000")Local$oDocument=_IEDocGetObj($oIE)Local$oWindow=$oDocument.ParentWindow$oWindow.setTimeout("document.body.JSeval = eval; ",0); a reference to the eval methodSleep(2000); give a little time to the browser to create above variables within the javascript environment.$JSeval=$oIE.Document.body.JSeval; a reference to the eval javascript method from within AutoIt$oSelect=$JSeval('$(".bootstrap-select > select")[0]')_IEFormElementOptionSelect($oSelect,"4673")

Share this post

Link to post

Share on other sites

Omnitica 0

Omnitica 0

#include <ie.au3>Local$oIE=_IEAttach("UR-000000")Local$oDocument=_IEDocGetObj($oIE)Local$oWindow=$oDocument.ParentWindow$oWindow.setTimeout("document.body.JSeval = eval; ",0); a reference to the eval methodSleep(2000); give a little time to the browser to create above variables within the javascript environment.$JSeval=$oIE.Document.body.JSeval; a reference to the eval javascript method from within AutoIt$oSelect=$JSeval('$(".bootstrap-select > select")[0]')_IEFormElementOptionSelect($oSelect,"4673")$JSeval('$(".bootstrap-select > select").change()')

I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
#include <IE.au3>
Local $oIE = _IECreate("http://questchecker.com/")
Local $iQuestID = "123456"
Local $sCharacterName = "CharacterName"
Local $colForms = _IEFormGetCollection($oIE)
$iCount = 0
For $oForm In $colForms
$oFormElements = _IEFormElementGetCollection($oForm)
For $oFormElement In $oFormElements
$iCount = $iCount + 1
Local $sTagName = StringLower($oFormElement.tagName)
Local $sElementType = $oFormElement.type
Local $sElementName = $oFormElement.name
Switch $iCount
Case 6
_IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm
Case 7
_IEFormElementSetValue($oFormElement, $sCharacterName, 0)
Case 8
_IEFormElementSetValue($oFormElement, $iQuestID, 0)
EndSwitch
Next
Next
Local $oButtons = _IEGetObjByName($oIE, "questForm")
For $oButton In $oButtons
If _IEFormElementGetValue($oButton) = "US" Then
MsgBox(0, "", "Click Okay to set focus")
_IEAction($oButton, "focus")
MsgBox(0, "", "Click Okay to click button")
_IEAction($oButton, "click")
ExitLoop
EndIf
Next
MsgBox(0, "", "Click Okay to quit")
_IEQuit($oIE)
Exit

As the title says. I open IE11 and navigate to a page with the following HTML5 file upload container in Capture0.JPG
I want to click Add Files but I haven't been able to. Here's the code that handles the Add Files button in Capture.JPG
_IEGetObjectById and then using _IEAction to click it doesn't work. I can't give access to the actual page unfortunately because it's password protected.
All suggestions welcome.

I have one script that creates _IECreateEmbedded and another script that does _IEAttach.
I do this because when autoit is doing something, the Embedded IE starts stalling (eg jquery progress animation)
But there is a new problem.
When IE is having its own process (like in the example above) any _IE command is slow (in the script that Attaches).
Here is a comparison of when its in separate and when its in same process:
Separate process _IETagNameGetCollection : 5000ms
Separate process _IEAction: 850ms
Same process _IETagNameGetCollection : 1ms
Same proccess _IEAction: 135ms

If I try to attach to an embedded IE that is done in c#, I get lightning fast results.
As you can see, _IE functions work very slow when the embedded IE we are attaching to is made in Autoit.

I did a test and if I empty the WHILE loop in IE process I get these results(but the cpu is at 30% as expected):
Separate process _IETagNameGetCollection : 33ms
Separate process _IEAction: 13ms