WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: hdsouza on December 16, 2014, 06:13:50 PM

Title: Selecting an item from a drop down which needs compatibility view
Post by: hdsouza on December 16, 2014, 06:13:50 PM
I need to select an item from a drop down list in IE
The code will not work until I enable countability view option in IE

Code (winbatch) Select

Count_Select = 3
objEvent = msie.document.createEvent("HTMLEvents") ; needed for compatability mode
MySelect = msie.document.getElementsByTagName("select").item(0)
If objEvent == "" Then ; needed for compatability mode
   MySelect.Options.item(Count_Select).selected = @TRUE ; WORKS
Else
   objEvent.initEvent("SELECT", @true, @true) ; what is the correct syntax
   MySelect.Options.item(Count_Select).dispatchEvent(objEvent) = @true ; what is the correct syntax
EndIf

Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: stanl on December 17, 2014, 07:11:59 AM
There is a Registry Setting

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation
REG_DWORD valeu - MSCompatibilityMode
Enabled - 1
Disabled - 0

Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: hdsouza on December 17, 2014, 01:54:44 PM
Quote from: stanl on December 17, 2014, 07:11:59 AM
There is a Registry Setting

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation
REG_DWORD valeu - MSCompatibilityMode
Enabled - 1
Disabled - 0

Hi Stan, The registry change does not appear to be working in IE 11. I also added the  REG_DWORD manually in. No luck
Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: hdsouza on December 19, 2014, 10:57:18 AM
Anyone know the correct syntax for objEvent as above?

Please help
Thanks
Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: td on December 19, 2014, 02:55:58 PM
Try using 'check' instead of "SELECT" in initEvent.  The events are defined by input, i.e. mouse 'click', and not type of element.  Also don't see a reason for the '= @true' on the last line. 
Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: hdsouza on December 19, 2014, 09:53:38 PM
Quote from: td on December 19, 2014, 02:55:58 PM
Try using 'check' instead of "SELECT" in initEvent.  The events are defined by input, i.e. mouse 'click', and not type of element.  Also don't see a reason for the '= @true' on the last line.

Not sure what you mean by "The events are defined by input"

I tried this and no luck
Code (winbatch) Select

Count_Select = 3
objEvent = msie.document.createEvent("HTMLEvents")
MySelect = msie.document.getElementsByTagName("select").item(0)
If objEvent == "" Then ; needed for compatability mode
   MySelect.Options.item(Count_Select).selected = @TRUE ; WORKS
Else
   objEvent.initEvent("check", @true, @true)
   MySelect.Options.item(Count_Select).dispatchEvent(objEvent)
EndIf
Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: stanl on December 20, 2014, 08:31:49 AM
maybe checked, not check

function check(){     document.getElementById("myCheck").checked=true     }
Title: Re: Selecting an item from a drop down which needs compatibility view
Post by: hdsouza on December 22, 2014, 08:48:05 PM
Quote from: stanl on December 20, 2014, 08:31:49 AM
maybe checked, not check

function check(){     document.getElementById("myCheck").checked=true     }

Stan, I tried objEvent.initEvent("checked", @true, @true) , Unfortunately it does not select the option
I also tried objEvent.initEvent("clicked", @true, @true)  .. same result