Jump to content

IE.AU3 _IEFormElementOptionSelect does not stick[SOVLED]


 Share

Recommended Posts

First I want to thank everyone on the wealth of info on this forum.

I have looked at all the information on IE.AU3 that I could locate and I can not figure out how to accomplish what I need to do.

We have a web site that our core provider uses so we can unlock customers who fat finger their passwords.

I am trying to reset one option dropdown box but I jsut do not seem to be able to get it to work.

Using debug bar and dragging the document to find the element I get these two elements

CODE
<INPUT class=clsTextBoxLabel id=dEBBL.SoftwareRestrictFlag2 onkeydown="Bump('dEBBL.SoftwareRestrictFlag2', this.dropdown)" onblur="UnHighLightMe('dEBBL.SoftwareRestrictFlag2')" onmouseover="HighLightMe('dEBBL.SoftwareRestrictFlag2')" style="LEFT: 0px; VISIBILITY: visible; POSITION: relative; BACKGROUND-COLOR: #cacaca" onfocus="HighLightMe('dEBBL.SoftwareRestrictFlag2')" onmouseout="UnHighLightMe('dEBBL.SoftwareRestrictFlag2')" readOnly size=30 value="Auto-Exceeded Attempts" name=dEBBL.SoftwareRestrictFlag2 dropdown="DD1">

CODE

<INPUT type=hidden value=1 name=EBBL.SoftwareRestrictFlag2>

I noticed at the end of the first element the dropdown="DD1

so I went to that location in debug bar and it looks like this

<

CODE
SELECT class=clsDropDown id=DD onkeydown="WhatIsTheNewValue(0, this.options[this.selectedIndex].text, 'DD1')" style="FONT-SIZE: 8pt; LEFT: 600px; VISIBILITY: hidden; COLOR: black; FONT-FAMILY: Verdana; POSITION: absolute; TOP: 1440px" onchange=CheckRedraw(this.options[this.selectedIndex].value) size=1 name=DD1><OPTION value=0>(None)</OPTION><OPTION value=1 selected>Auto-Exceeded Attempts</OPTION><OPTION value=2>Auto-Exceeded Session Limit</OPTION><OPTION value=9>Manual</OPTION></SELECT>

I have tried coutless things to get it to work and so far have failed.

Here is my lattest attempt

#include <IE.au3>
#include <array.au3>

$oIE = _IEAttach ("Institution: 19")            ;reget the page
$hIE = _IEPropertyGet($oIE, "hwnd")

    $oFrame = _IEFrameGetObjByName ($oIE, "frmNavBottom")

    $oFrame2 = _IEFrameGetObjByName ($oFrame, "idBottom")
    $oForm = _IEFormGetObjByName ($oFrame2,"BottomRight")
    
    $oEles = _IEFormElementGetCollection($oForm)
    For $oEle In $oEles
    
    if $oEle.name = "DD1" Then
        $value_0 = $oEle.value

        ConsoleWrite("Initial Vaule is: " & $value_0 & @CRLF)
        sleep(100)
        $gopt = _IETagNameGetCollection($oEle,"OPTION")
        For $gop in $gopt 
            Global $option = $gop.innerText
        Sleep(500)
        ConsoleWrite("Lockout is: " & $option & @CRLF)
        if $option = "(None)" then
            
            _IEFormElementOptionselect($oEle, $option, 1, "byText")
            $text_name=_IEFormElementGetObjByName($oForm,"dEBBL.SoftwareRestrictFlag2")
            _IEFormElementSetValue($text_name,"(None)")
            $hidd_name=_IEFormElementGetObjByName($oForm,"EBBL.SoftwareRestrictFlag2")
            _IEFormElementSetValue($hidd_name,"0")
            $ocheckValue = _IELoadWait($oEle)
            
            ConsoleWrite("after select " & $option & @CRLF)
                $value_0 = $oEle.value
                ConsoleWrite("Initial Vaule is: " & $value_0 & @CRLF)
        Endif
            Sleep(500)
        Next
        
    endif       
    Next

I am able to change straight INPUT Text areas on this screen fine.

After I run this the screen looks correct but when I click update and then return it is back to the "lockout" setting.

the begining of the autoit code is just to get me to the correct form.

If anyone could point me to what I am doing wrong I would greatly apreciate it.

Jim

Edited by jim read
Link to comment
Share on other sites

Doesn't this part of the code pretty much say "If the option is '(None)' then change it to '(None)'"?

For $gop In $gopt
    Global $option = $gop.innerText
    Sleep(500)
    ConsoleWrite("Lockout is: " & $option & @CRLF)
    If $option = "(None)" Then
        _IEFormElementOptionselect($oEle, $option, 1, "byText")
        
    ; ...<snip>
        
    EndIf
    
; ...<snip>
    
Next

:)

Edit: Nevermind, I get "if any available option tag is "(None)" then set the selection to "(None)". That makes more sense.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Since the HTML uses onkeydown to trigger a script to read the value, perhaps you have to do it this way to get that event to fire:

; _IEFormElementOptionselect($oEle, $option, 1, "byText")
                _IEAction($oEle, "focus")
                ControlSend($hIE, "", "", $option)

The default event fired is probably onclick, not onkeydown.

:)

Edit: Here's the code from the IE.au3 UDF:

If $f_fireEvent Then
                                    $o_object.fireEvent("onchange")
                                    $o_object.fireEvent("onclick")
                                EndIf

So you might be able to just do this:

_IEFormElementOptionselect($oEle, $option, 1, "byText", 0); 0 = Don't fire default event
$oEle.fireEvent("onkeydown")

Dale would know... I'm not sure...

:)

Edit 2: Added parameter to not fire default event per Dale, below.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Good job.

You are right on the mechanics of the event firing. It may take some playing around to get the sequence to work properly. It may take turning off the default event firing (optional parameter to _IEFormElementOptionselect) and firing them manually as you have shown with $oEle.fireEvent

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Thank you both;

I had to mess around a bunch but this finally is what worked.

$oIE = _IEAttach ("Institution: 19")            ;reget the page
$hIE = _IEPropertyGet($oIE, "hwnd")

    $oFrame = _IEFrameGetObjByName ($oIE, "frmNavBottom")

    $oFrame2 = _IEFrameGetObjByName ($oFrame, "idBottom")
    $oForm = _IEFormGetObjByName ($oFrame2,"BottomRight")
    
    $oEles = _IEFormElementGetCollection($oForm)
    For $oEle In $oEles
    
    if $oEle.name = "DD1" Then
        $value_0 = $oEle.value

        ConsoleWrite("Initial Vaule is: " & $value_0 & @CRLF)
        sleep(100)
        $gopt = _IETagNameGetCollection($oEle,"OPTION")
        For $gop in $gopt 
            Global $option = $gop.innerText
        Sleep(500)
        ConsoleWrite("Lockout is: " & $option & @CRLF)
        if $option = "(None)" then
            
            $text_name=_IEFormElementGetObjByName($oForm,"dEBBL.SoftwareRestrictFlag2")
            
            $text_name.fireEvent("onmousedown")
            ConsoleWrite("oonfocus"& @CRLF)
            sleep(500)
            _IEFormElementSetValue($text_name,"(None)")
            
            
            $hidd_name=_IEFormElementGetObjByName($oForm,"EBBL.SoftwareRestrictFlag2")
            _IEFormElementSetValue($hidd_name,"0")
            
            $oEle.fireEvent("oncontrolselect")
            ConsoleWrite("oncontextmenu"& @CRLF)
            sleep(500)
            _IEFormElementOptionselect($oEle, $option, 1, "byText",0)
            ControlSend($hIE, "", "", $option) 
                                    $oEle.fireEvent("onkeydown")
            ConsoleWrite("onkeydown"& @CRLF)
            sleep(500)
            $oEle.fireEvent("onchange")
            ConsoleWrite("onchange" & @CRLF)
            sleep(500)
            $text_name.fireEvent("onfocusout")
            ConsoleWrite("oonfocus"& @CRLF)
            sleep(500)

I am not positive all of this is needed but this sequence did the trick.

Thanks Again

Edited by jim read
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...