Jump to content

[Solved] _IE unable to find or read obj


Recommended Posts

So I've been trying for awhile now to get this to work, but it seems the objects are hidden or something.
I'm trying to read one Obj on a page by Id, and grab the innerText, but every time I get this error:

Success! <-- locationurl -->
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (message)
"F:\Script\Hassett 4.0.au3" (32) : ==> Variable must be of type "Object".:
ConsoleWrite($HTML.innerText & @CRLF)
ConsoleWrite($HTML^ ERROR


I've tried to same method with Google search, and it will find and read the search box just fine as a test. 
Using iWB2 Learner it is able to find the Obj I need.

Title: *business, cannot post*
Url: *business, cannot post*
Index: 19,   Name: ,  Id: message
Frame.#: IFRAME.1,  Index: 52,  Name: mainBody,  Id: mainBody
InnerText:
 Container ID : LAXSEA18047120404 Unloaded successfully.
OuterHTML:
 <span class="successMsgBig" id="message">Container ID : LAXSEA18047120404 Unloaded successfully.</span>


My code:
 

Local $Error_Code = [0, 0, 0, 0, 0, '_IEStatus_InvalidValue', 0, '_IEStatus_NoMatch']
Local $IE = _IEAttach('Unload Container')
If @error Then Exit ConsoleWrite('::Error:: ' & $Error_Code[@error] & @CRLF)
ConsoleWrite('Success! ' & _IEPropertyGet($IE, 'locationurl') & @CRLF)
Local $HTML = _IEGetObjById($IE, 'message')
ConsoleWrite($HTML.innerText & @CRLF)

 

Edited by FengHuangWuShen
Link to comment
Share on other sites

Are you able to post the HTML code minus any private information?  Using the following works fine for me, so guessing its something else on the page:

#include <IE.au3>
Local $oIE = _IEAttach("Unload Container")
ConsoleWrite('Success! ' & _IEPropertyGet($oIE, 'locationurl') & @CRLF)
Local $sMessage = _IEGetObjById($oIE, 'message')
ConsoleWrite($sMessage.innertext & @CRLF)

 

<html>
<head>
<title>Unload Container</title>
</head>
<body>
<span class="successMsgBig" id="message">Container ID : LAXSEA18047120404 Unloaded successfully.</span>
</body>
</html>

 

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />












<title>Unload Container</title>


<link rel="stylesheet" type="text/css" href="/OTMNowViewPoint/combined.css?id=10483ce015b0a5a" >

<link rel="stylesheet" type="text/css" href="js/jeasyui-1.4.3/themes/icon.css">
<link rel="stylesheet" type="text/css" href="js/jeasyui-1.4.3/themes/default/easyui_default.css">

<script type="text/javascript" src="js/otm/comm/rt.js" ></script>
<script type="text/javascript" src="js/jquery/1.10/jquery.min-1.10.js"></script>
<script type="text/javascript" src="js/jeasyui-1.4.3/jquery.easyui.min.js"></script>


<script type="text/javascript" src="js/viewpoint/unload_containers.js"></script>


<style type="text/css">
.edited-cell {
    /* background: url("images/dirty.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0) !important; */
    background:  url("images/dirty.png") no-repeat scroll 0 0 yellow !important;
}
.green-row {
    background: scroll 0 0 #BFFF00 !important;
}
.red-row {
    background: scroll 0 0 #ff8080 !important;
}
 input[type=button] {
   background-color:#dedede;
   cursor: pointer;
   cursor: hand;
 }
 input[type=button]:disabled {
   cursor: not-allowed;
 }
.ui-datepicker-trigger {
    vertical-align: bottom;
}
.buttondisabled {
    opacity: 0.5;  /* Opacity for Modern Browsers */
    filter: alpha(opacity=50);  /* Opacity for IE8 and lower */
    zoom: 1;  /* Fix for IE7 */
    cursor: not-allowed;
}
.disabled {
    opacity: 0.5;  /* Opacity for Modern Browsers */
    filter: alpha(opacity=50);  /* Opacity for IE8 and lower */
    zoom: 1;  /* Fix for IE7 */
    cursor: auto;
    background-color:#eee;
}

.inputloading {
    background-image: url("images/ajax-loader.gif")!important;
    background-position:right center !important;
    background-repeat: no-repeat !important;
}


</style>

<script type="text/javascript" >
    if (document.title) {
        window.parent.document.title = 'Unload Container';
    }
    var hide_img="images/themes/themesswanblue.6.0/hide.gif";
    var show_img="images/themes/themesswanblue.6.0/show.gif";

    $(function(){
        //$('#UnloadDSPSupplyDig').dialog('close');
        //$('#dialogs').show();

        $('.easyui-tooltip').click(function(e) {
             $(this).tooltip("hide");
        });
        //$("#SearchButton").focus();
        $(document).keypress(function(e) {
            if(e.which == 13 ) {
                //$("#SearchButton").focus();
                $("#SearchButton").click()
            }
        });
     });

    (function($) {
        $.fn.tooltip.defaults = {
                position: "right",
                content: null,
                trackMouse: false,
                deltaX: 0,
                deltaY: 0,
                showEvent: "mouseenter",
                hideEvent: "mouseleave",
                showDelay: 800,
                hideDelay: 100,
                onShow: function(e) {},
                onHide: function(e) {},
                onUpdate: function(_20a) {},
                onPosition: function(left, top) {},
                onDestroy: function() {}
         };

        $(document).on('mouseenter', '.datebox', function(){
            var name = $(this).find('input[type=hidden]').attr('name');
            if(name == 'actualArrivalDate'){
                $(this).tooltip({
                    position: "right",
                    showDelay: 800,
                    hideDelay: 100,
                    content: '<b>Actual Arrival Date</b><br>Enter the actual date and time when the driver arrives the DC.',
                });
                $(this).tooltip("show");
            }else if(name == 'actualDepartureDate'){
                $(this).tooltip({
                    position: "right",
                    showDelay: 800,
                    hideDelay: 100,
                    content: '<b>Actual Departure Date</b><br>Enter the actual date and time that the dock clerk has provided the driver with the copies of the signed paperwork.',
                });
                $(this).tooltip("show");
            }

        });

    })(jQuery);

    //Override the $.fn.[plugin].defaults.panelHeight
    $.map(['combo','combobox','combogrid','combotree','datebox','datetimebox'], function(plugin){
        $.fn[plugin].defaults.panelHeight = 'auto';
        if(plugin=='datetimebox' ){
            $.fn[plugin].defaults.showSeconds = false;
        }
        else if(plugin=='combo' || plugin=='combobox'){
            $.fn[plugin].defaults.editable = false;
        }
    });
    var UNLOADED_CONTAINER_DATA         = {"total":19,"page":1,"records":19,"success":true,"rows":[{"CONTAINER_ID":"LAXSEA18047120404","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA18047120404","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA18047120405","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA18047120405","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA18047120406","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA18047120406","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA18047120409","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA18047120409","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047120958","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047120958","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047120959","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047120959","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047120960","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047120960","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047121059","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047121059","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047121061","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047121061","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"LAXSEA19047121071","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.LAXSEA19047121071","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USLAX1"},{"CONTAINER_ID":"PHXSEA18047558911","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558911","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"PHXSEA18047558918","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558918","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"PHXSEA18047558926","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558926","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"PHXSEA18047558932","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558932","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"PHXSEA18047558940","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558940","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"PHXSEA18047558954","CONTAINER_TYPE":"GAYLORD 46IN ON ORANGE PALLET","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.PHXSEA18047558954","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USPHX1"},{"CONTAINER_ID":"SFOSEA19047404164","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.SFOSEA19047404164","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USSFO1"},{"CONTAINER_ID":"SFOSEA19047404165","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.SFOSEA19047404165","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USSFO1"},{"CONTAINER_ID":"SFOSEA19047404166","CONTAINER_TYPE":"COLLAPSIBLE BIN 47.9 X 44.9 X 50.0","DESTINATION":"USSEA1","ORDER_RELEASE_GID":"DHLGM.SFOSEA19047404166","UNLOADED":"N","IS_OVERAGE":"N","ORIGIN":"USSFO1"}]};
    var CONTAINER_TYPE_OPTIONS          = [];
    var ORIGIN_LOCATION_OPTIONS         = [];
    //var DESTINATION_LOCATION_OPTIONS  = ;

    var grid_height = $(window).height() - 350;

    $(function(){
            $('#UnloadContainerGrid').datagrid({
                remoteSort  :false,
                height      :grid_height,
                striped     :true,
                fitColumns  :true,
                nowrap      :true,
                fit         :false,
                emptyMsg    : 'No Data Found.',
                frozenColumns:[[]],
                columns:[[
                          {"field":"CONTAINER_ID","halign":"center","title":"Container ID","hidden":false,"align":"left","width":"200px"},
                          {"field":"CONTAINER_TYPE","halign":"center","title":"Container Type","hidden":false,"align":"left","width":"250px"},
                          {"field":"ORIGIN","halign":"center","title":"Origin","hidden":false,"align":"left","width":"200px"},
                          {"field":"DESTINATION","halign":"center","title":"Destination","hidden":false,"align":"left","width":"200px"},
                          {"field":"UNLOADED","halign":"center","title":"Unloaded","hidden":false,"align":"center","width":"80px","formatter":UnloadedFormatter},
                          {"field":"UNDO","halign":"center","title":"Undo","hidden":false,"width":"60px","align":"center","formatter":undoFormatter},
                          {"field":"IS_OVERAGE","halign":"center","title":"OVERAGE","hidden":true},
                          {"field":"ORDER_RELEASE_GID","halign":"center","title":"ORDER_RELEASE_GID","hidden":true}

                        ]]
             }).datagrid('loadData', UNLOADED_CONTAINER_DATA);

            reCalculateFooter();
            processRowColor();

     });

    $(document).ready(function() {
        //below will works on dyanamic added elements too
        $(document).on('keyup', '.datagrid-editable-input', function(){
            setDirty($(this));
        });
        $(document).on('keyup change', '.textbox-value', function(){
            setDirty($(this));
        });
        $(document).on('keyup change', '.datagrid-editable', function(){
            setDirty($(this));
        });
        $(document).on('keyup change', '.easyui-combobox', function(){
            setDirty($(this));
        });

        ///////////////////////////////////////////////////////
        
            $('#unloadDSPSupplyBtn').prop('disabled', true);
        
        
        ///////////////////////////////////////////////////////
        
            $('#unloadBOLBtn').prop('disabled', true);
        
        

        ///////////////////////////////////////////////////////
        
            $('#finishLoadStartBtn').prop('disabled', true);
        
        
        ///////////////////////////////////////////////////////
        
        
            $('#tamperedSealChk').prop('checked', false);
        
        ///////////////////////////////////////////////////////

    });
</script>

</head>

<body class="body" >

        <div id="header"  style="overflow-y: auto;">

                <div id="messagePanel" class="easyui-panel" style="width: 98%; display: none; padding-left: 2px;">
                    <span id="message" ></span>
                </div>

                <div class="bodyHeaderCont" style="padding-bottom: 5px;">
                    <table cellspacing="0" cellpadding="0" border="0" style="width: 100%;" class="hdLine">
                        <tr valign="bottom">
                            <td nowrap="true" style="width: 33%;" class="hdTitle"  id="pageHeaderTitle">Unload Container</td>
                        </tr>
                    </table>
                </div>

                <div class="headerFieldsCont">
                    <img width="1" height="0.5" src="images/themes/themesswanblue.6.0/spacer.gif" >
                </div>
                <div style="clear: both"></div>
        </div>



    <div id="content" class="bodyDataCont" style="overflow-y: auto;">
                        <div id="bodyDataContDiv">
                                <form id="UnLoadContainersForm" name="UnLoadContainerForm" action="findAllUnLoadContainer" method="post">
                                <div style="clear: both"></div>
                                        <input id="shipmentGid" name="shipmentGid" type="hidden" value="DHLGM.2556780"/>
                                        <input id="stopNum" name="stopNum" type="hidden" value="3"/>

                                        <div class="bodySectCont ">
                                        <table>
                                        <tr>
                                        <td style="vertical-align: top;">
                                                <table style="padding-left:5px; width: 100%">
                                                        <tr>
                                                                <td style="width: 30%;">
                                                                        <div class="fieldCont">
                                                                                <div class="fieldLabel">Shipment ID</div>
                                                                                <input id="shipmentXid" name="shipmentXid" disabled="disabled" type="text" value="2556780" size="25"/>
                                                                        </div>
                                                                </td>

                                                                <td style="width: 30%;">
                                                                        <div class="fieldCont">
                                                                                <div class="fieldLabel">Distribution Center</div>
                                                                                <input id="mtName" name="mtName" disabled="disabled" type="text" value="USSEA1" size="35"/>

                                                                </div>
                                                                </td>

                                                                <td style="width: 30%;">
                                                                    <div class="fieldCont">
                                                                        <div class="fieldLabel">Actual Arrival Date</div>
                                                                        
                                                                        <input id="actualArrivalDate" name="actualArrivalDate" class="easyui-tooltip easyui-datetimebox" style="min-width: 150px;" data-options="tooltip:{content:&#39;&lt;b&gt;Actual Arrival Date&lt;/b&gt;&lt;br&gt;Enter the actual date and time when the driver arrives the DC.&#39;}" type="text" value=""/>
                                                                        <script type="text/javascript" >
                                                                            $(document).ready(function() {
                                                                                $('#actualArrivalDate').datetimebox({
                                                                                    value: '',
                                                                                    required: false,
                                                                                    showSeconds: false,
                                                                                    tooltip:{content:'<b>Actual Arrival Date</b><br>Enter the actual date and time when the driver arrives the DC.'}
                                                                                });
                                                                            });
                                                                        </script>
                                                                    </div>

                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td style="width: 30%;">
                                                                        <div class="fieldCont">
                                                                                
                                                                                <div class="fieldLabel">Trailer #</div>
                                                                                <input id="trailerNumber" name="trailerNumber" class="easyui-tooltip" title="&lt;b&gt;Trailer #&lt;/b&gt;&lt;br&gt;Enter the trailer number." type="text" value="" size="25"/>
                                                                </div>
                                                                </td>

                                                                <td style="width: 30%;">
                                                                        <div class="fieldCont">
                                                                                <div class="fieldLabel">Vendor Name</div> <input id="vendorName" name="vendorName" disabled="disabled" type="text" value="JUST IN TIME CARGO, INC." size="35"/>

                                                                </div>
                                                                </td>

                                                                <td style="width: 30%;">
                                                                    <div class="fieldCont">
                                                                        <div class="fieldLabel">Actual Departure Date</div>
                                                                        
                                                                        <input id="actualDepartureDate" name="actualDepartureDate" class="easyui-tooltip easyui-datetimebox" style="min-width: 150px;" type="text" value=""/>
                                                                        <script type="text/javascript" >
                                                                            $(document).ready(function() {
                                                                                $('#actualDepartureDate').datetimebox({
                                                                                    value: '',
                                                                                    required: false,
                                                                                    showSeconds: false,
                                                                                    tooltip:{content:'<b>Actual Departure Date</b><br>Enter the actual date and time that the dock clerk has provided the driver with the copies of the signed paperwork.'}
                                                                                });
                                                                            });
                                                                        </script>

                                                                    </div>

                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td style="width: 30%;">
                                                                        <div class="fieldCont">
                                                                                
                                                                                <div class="fieldLabel">Seal</div>
                                                                                <input id="sealNumber" name="sealNumber" class="easyui-tooltip" title="&lt;b&gt;Seal #&lt;/b&gt;&lt;br&gt;The seal is mandatory if the shipment came from another DHL eCommerce DC. If the vehicle was not sealed, mark the tamper seal checkbox." type="text" value="" size="25"/>
                                                                        </div>
                                                                </td>
                                                                <td style="width: 30%;">
                                                                    <div>
                                                                        <div class="fieldLabel" style="float: left;">
                                                                        <div><input type="checkbox"  id="tamperedSealChk" name="tamperedSealChk" cstyle="display:inline;"  class="easyui-tooltip" title="" />
                                                                            <div class="fieldLabel" style="display:inline;"> <a href="#" id="tamperedSealLink" >Tampered Seal </a></div>
                                                                        </div>
                                                                        </div>
                                                                    </div>
                                                                </td>
                                                        </tr>
                                                </table>
                                                </td>
                                                <td style="vertical-align: top;">
                                                    <div class="fieldCont">
                                                                
                                                                <div class="fieldLabel">Shipment Stops</div>
                                                                <select id="stopNumSelect" name="stopNumSelect" class="easyui-tooltip" title="&lt;b&gt;Shipment Stops&lt;/b&gt;&lt;br&gt;This displays all the stops in the shipment in order." multiple="multiple">
                                                                    <option value="USLAX1#1">USLAX1</option><option value="USSFO1#2">USSFO1</option><option value="USSEA1#3" selected="selected">USSEA1</option>
                                                                </select><input type="hidden" name="_stopNumSelect" value="1"/>
                                                    </div>

                                                </td>
                                                </tr>


                                        </div>

                                </form>
                        </div>

                        <div class="headerFieldsCont"><img width="1" height="1" src="images/themes/themesswanblue.6.0/spacer.gif"></div>
                        <div class="cl" style="padding-bottom: 5px;"></div>
                            <table >
                                <tbody>
                                        <tr>
                                                <td>
                                                        <div style="" class="fieldLabel">Container ID (to be scanned)</div>
                                                </td>
                                                <td>
                                                        <div class="fieldCont"><input type="text" id="containerId" name="containerId" class="easyui-tooltip" title="<b>Container ID (to be scanned)</b><br>Scan the container barcode."/></div>
                                                </td>
                                                <td>
                                                        <div style="padding-left: 20px;"><input type="button" href="#" name="unloadContainerBtn" id="unloadContainerBtn" value="Unload Container" class="easyui-tooltip" title="<b>Unload Container</b><br>Click this button to unload the Container entered."></div>
                                                </td>

                                                <td>
                                                        <div style="padding-left: 20px;"><input type="button" href="#" name="unloadDSPSupplyBtn" id="unloadDSPSupplyBtn" value="Unload DSP Supply" class="easyui-tooltip" title="<b>Unload DSP Supply</b><br>Click here to create supply containers to unload them from the shipment."></div>
                                                </td>

                                        </tr>

                                </tbody>
                        </table>

                        <div class="bodySectCont">
                                <div id="CONTAINERS_SECTION">
                                        <div class="panel-header" style="padding: 0px;"><a href="javascript:showHideSection('CONTAINERS_TABLE', 'image_CONTAINERS_TABLE');"> <img border="0"
                                                        src="images/themes/themesswanblue.6.0/hide.gif" title="Expand" alt="Expand" style="vertical-align: middle;" id="image_CONTAINERS_TABLE"></a>
                                                <span class="fieldLabel" id="label_CONTAINERs_TABLE">Containers</span></div>
                                        <div>
                                                <div id="CONTAINERS_TABLE">
                                                    <table id="UnloadContainerGrid"></table>
                                                </div>
                                                <div class="cl" style="padding-bottom: 5px;"></div>
                                        </div>

                                </div>
                        </div>




                <div>
                        <table  class="bodySectInCont w100">
                            <tbody>
                                    <tr>
                                            <td>
                                                <div style="padding-right: 20px;" class="fieldLabel">Total:
                                                </div>
                                            </td>
                                            <td>
                                                <div style="padding-right: 40px;" class="fieldLabel"> Total Container Unloaded : <input disabled="disabled"  id="totalUnloadedContainers" name="totalUnloadedContainers" value="" size="10">
                                                </div>
                                            </td>
                                            <td>
                                                <div style="padding-right: 40px;" class="fieldLabel"> Expected to unload : <input disabled="disabled"  id="totalExpectedToUnload" name="totalExpectedToUnload" value="" size="10">
                                                </div>
                                            </td>
                                            <td>
                                                <div style="padding-right: 20px;" class="fieldLabel">Addtional(overage) : <input disabled="disabled"  id="totalOverage" name="totalOverage" value="" size="10">
                                                </div>
                                            </td>
                                    </tr>
                            </tbody>
                        </table>
                </div>

                        <div  class="hdLine"></div>
                        <table  class="bodySectInCont w100">
                            <tbody>
                                    <tr>
                                            <td><input type="button" name="saveContainersBtn" id="saveContainersBtn" value="Save" class="easyui-tooltip" title="<b>Save</b><br>Click here to save the details entered in the shipment."></td>
                                            <td><input type="button" name="saveExitBtn" id="saveExitBtn" value="Save & Exit" class="easyui-tooltip" title="<b>Save & Exit</b><br>Click here to save the details entered in the shipment and exit the screen."></td>
                                            <td><input type="button" name="finishLoadExitBtn" id="finishLoadExitBtn" value="Finish Unload & Exit" class="easyui-tooltip" title="<b>Finish Unload & Exit</b><br>Click here to exit screen after finishing unloading all Containers."></td>
                                            <td><input type="button" name="unloadBOLBtn" id="unloadBOLBtn" value="Unload BOL" class="easyui-tooltip" title="<b>Unload BOL</b><br>Click here to unload BOLs from this shipment."></td>
                                            <td><input type="button" name="finishLoadStartBtn" id="finishLoadStartBtn" value="Finish Unload & Start Load" class="easyui-tooltip" title="<b>Finish unload & Start Load</b><br>Click here if you have finished unloading the containers and you need to load containers to this shipment."></td>
                                            <td><input  type="button"  name="cancelBtn" id="cancelBtn" value="Cancel" class="easyui-tooltip" title="Cancel"></td>
                                    </tr>

                            </tbody>
                        </table>
            </div>

    <div id="dialogs" style="display: none;">
            <div id="UnloadDSPSupplyDig" class="easyui-dialog" title="Create Container"
            data-options="buttons:'#UnloadDSPSupplyButtonBox',modal:true,closed:true">
                    <div class="bodySectCont">
                    <span id="messageUnloadDSPSupply" class="fieldLabel" style="color:red;"></span>

                    <form id="UnloadDSPSupplyForm" name="UnloadDSPSupplyForm">
                            <div style="clear: both"></div>
                                <table style="padding: 5px;width: 100%">
                                    <tbody>

                                        <tr>
                                            <td >
                                                <div class="fieldLabel">Type</div>
                                            </td>
                                            <td >
                                                <div class="fieldCont">
                                                <input type="hidden" id="dspType" name="dspType" value="DSP_SUPPLY" style="width:270px;">
                                                <input disabled="disabled" id="dspTypeName" name="dspTypeName" value="DSP Supply" style="width:270px;">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td >
                                                <div class="fieldLabel">Destination</div>
                                            </td>
                                            <td >
                                                <div class="fieldCont">
                                                    <input id="dspDestination" name="dspDestination" value="USSEA1" style="width:270px;" disabled="disabled">
                                                    <input type="hidden" id="dspDestinationGid" name="dspDestinationGid" value="DHLGM.USSEA1" style="width:270px;">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td >
                                                <div class="fieldLabel"># of Containers</div>
                                            </td>
                                            <td >
                                                <div class="fieldCont">
                                                    <input id="dsp_no_of_containers" name="dsp_no_of_containers" value="" style="width:270px;" onkeyup="this.value=this.value.replace(/[^\d]/,'')">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td >
                                                <div class="fieldLabel">Origin</div>
                                            </td>
                                            <td >
                                                <div class="fieldCont">
                                                    <input class="easyui-combobox" id="dspOrigin" name="dspOrigin" style="width:275px;" data-options="valueField:'value',textField:'name',data:ORIGIN_LOCATION_OPTIONS,editable:false">

                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td >
                                                <div class="fieldLabel">Container Type</div>
                                            </td>
                                            <td >
                                                <div>
                                                        <input class="easyui-combobox" id="dspContainerType" name="dspContainerType" style="width:275px;" data-options="valueField:'value',textField:'name',data:CONTAINER_TYPE_OPTIONS,editable:false">
                                                </div>
                                            </td>
                                        </tr>

                                    </tbody>
                                </table>
                    </form>
                    </div>
                <div id="UnloadDSPSupplyButtonBox">
                     <input  type="button" data-options="iconCls:'icon-save'" id="submitUnloadDSPSupplyBtn"  value="Save" class="easyui-tooltip" title="<b>Save & Print Label(s)</b><br>Click here to Save & Print Label(s)."/>
                     <input  type="button" data-options="iconCls:'icon-cancel'" onclick="$('#UnloadDSPSupplyDig').dialog('close');" value="Cancel" class="easyui-tooltip" title="<b>Close</b><br>Click here to close."/>
                </div>
            </div>



        <div id="tamperedSealDig" class="easyui-dialog" title="Tampered Seal" style="width:450px;height:300px;" data-options="buttons:'#tamperedSealButtonBox',modal:true">

                    <div class="bodySectCont">
                    <span id="messageTamperedSeal" class="fieldLabel" style="color:red;"></span>


                    <div class="bodyHeaderCont" >
                        <table cellspacing="0" cellpadding="0" border="0"  class="hdLine" style="padding: 5px;">
                            <tr valign="bottom">
                                <td nowrap="true" style="width: 33%" class="hdTitle" id="pageHeaderTitle">Please enter reason for tampered seal.</td>
                            </tr>
                        </table>
                    </div>

                    <input type="hidden" name="hiddenTempSealReason" id="hiddenTempSealReason" value=""/>
                    <input type="hidden" name="hiddenTempSealDesc" id="hiddenTempSealDesc" value=""/>

                    <form id="tamperedSealForm" name="tamperedSealForm" action="/OTMNowViewPoint/openUnloadContainer.do" method="post">
                        <div style="clear: both"></div>
                        <table class="bodySectInCont w100" style="padding: 5px;">
                            <tbody>
                                <tr>
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Shipment ID</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">
                                            <input id="tamperedSealShipment" name="tamperedSealShipment" value="2556780" readonly="readonly" class="disabled">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Tampered Seal Reason</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">
                                                <select id="tamperedSealReason" name="tamperedSealReason">
                                                    <option value="Driver broke the seal">Driver broke the seal</option><option value="Seal does not match">Seal does not match</option><option value="Missing seal">Missing seal</option><option value="Seal improperly applied">Seal improperly applied</option><option value="Typo error from the loading terminal">Typo error from the loading terminal</option><option value="Seal previously used in another shipment">Seal previously used in another shipment</option><option value="Other">Other</option>
                                                </select>
                                        </div>
                                    </td>
                                </tr>
                                <!-- Display only when "Other" reason is selected -->
                                <tr id="descRow" style="display: none;">
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Reason Description*</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">
                                            <textarea id="tamperedSealDescription" name="tamperedSealDescription" rows="3" cols="25" maxlength="50"></textarea>
                                        </div>
                                    </td>
                                </tr>

                            </tbody>
                        </table>
                        </form>
                    </div>

                    <div id="tamperedSealButtonBox">
                         <input  type="button" data-options="iconCls:'icon-save'" id="tamperedSealBtn" value="Save"/>
                         <input  type="button" data-options="iconCls:'icon-cancel'" onclick="$('#tamperedSealDig').dialog('close');" value="Close"/>
                    </div>

            </div>

            <div id="reopenShipmentDig" class="easyui-dialog" title="Reopen Reason" style="width:450px;height:300px;" data-options="buttons:'#reopenButtonBox',modal:true">
                    <div class="bodySectCont">
                    <span id="messageReopenShipment" class="fieldLabel" style="color:red;"></span>
                    <div class="bodyHeaderCont" >
                        <table cellspacing="0" cellpadding="0" border="0"  class="hdLine" style="padding: 5px;">
                            <tr valign="bottom">
                                <td nowrap="true" style="width: 33%" class="hdTitle" id="pageHeaderTitle">Shipment was closed and needs to reopened</td>
                            </tr>
                        </table>
                    </div>
                    <form id="reopenShipmentForm" name="reopenShipmentForm" action="/OTMNowViewPoint/openUnloadContainer.do" method="post">
                        <div style="clear: both"></div>
                        <table class="bodySectInCont w100" style="padding: 5px;">
                            <tbody>
                                <tr>
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Shipment ID</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">
                                            <input id="reopenShipment" name="reopenShipment" value="" readonly="readonly" class="disabled">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Reopen Reason</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">

                                                <select id="reopenReason" name="reopenReason">
                                                    <option value="DELAYED RECEIVING/INTERRUPTION">DELAYED RECEIVING/INTERRUPTION</option><option value="EQUIPMENT FAULT">EQUIPMENT FAULT</option><option value="STAFF ERROR">STAFF ERROR</option><option value="OTHER">OTHER</option>
                                                </select>
                                        </div>
                                    </td>
                                </tr>
                                <!-- Display only when "Other" reason is selected -->
                                <tr id="descRow" style="display: none;">
                                    <td style="width: 150px">
                                        <div class="fieldLabel">Description*</div>
                                    </td>
                                    <td>
                                        <div class="fieldCont">
                                            <textarea id="reopenDescription" name="reopenDescription" rows="3" cols="25"></textarea>
                                        </div>
                                    </td>
                                </tr>

                            </tbody>
                        </table>
                        </form>
                    </div>
                    <div id="reopenButtonBox">
                         <input  type="button" value="Reopen and Load Container" id="reopenShipmentBtn" />
                         <input  type="button"  onclick="$('#reopenShipmentDig').dialog('close');" value="Cancel"/>
                    </div>
            </div>

</div>

</div>



<div style="display:none" class="datagrid-mask"></div>
<div style="display:none; left: 50%; height: 16px; margin-left: -81.5px; line-height: 14px;font-size:12px;" class="datagrid-mask-msg">
    Processing, please wait ...
</div>

</body>


<script type="text/javascript" src="js/viewpoint/viewpoint_common.js"></script>
</html>

I guess there really isn't much sensitive data, but without credentials, you'll be unable to replicate the real webpage.


Full code:

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\ICO\Custom-Icon-Design-Flatastic-11-Search-good.ico
#AutoIt3Wrapper_Outfile=..\Compiled\Receive+.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <IE.au3>
#Include <Array.au3>
TrayTip('Viewpoint Manager', 'Script has started.', 1)
;MsgBox(0, 'Instructions', '1. CTRL+A to select, then CTRL+C to copy all containers to the clipboard.' & @CRLF & '2. Press INSERT (INS) to start.' & @CRLF & '3. Press END to close the script.')

#Region HOTKEY
HotKeySet('{INSERT}', 'INPUT_CONTAINER')
HotKeySet('{END}', 'EXT')
#EndRegion

#Region Reference
Global $STATIC_DC = ['ATL', 'RDU', 'MCO', 'MEM' & _
                     '', 'BWI', 'PHX', 'BOS', 'STL' & _
                     '', 'CVG', 'EWR', 'DFW', 'ORD' & _
                     '', 'DEN', 'SLC', 'LAX', 'SFO' & _
                     '', 'SEA']

Global $STATIC_TTDWPX = ['99M899374120011048913']

Global $STATIC_TITLE = [0, 'HASSETT', 'SCF', 'RECEIVING', 'ERROR']
#EndRegion

Local $Error_Code = [0, 0, 0, 0, 0, '_IEStatus_InvalidValue', 0, '_IEStatus_NoMatch']
Local $IE = _IEAttach('Unload Container')
If @error Then Exit ConsoleWrite('::Error:: ' & $Error_Code[@error] & @CRLF)
ConsoleWrite('Success! ' & _IEPropertyGet($IE, 'locationurl') & @CRLF)
Local $HTML = _IEGetObjById($IE, 'message')
ConsoleWrite($HTML.innerText & @CRLF)

#Region Functions
Func INPUT_CONTAINER()
    $STATIC_TITLE[0] = 1
    Local $CONTAINER_STRING = StringStripWS(ClipGet(), 8)
    Local $CONTAINER_LIST = StringRegExp($CONTAINER_STRING, "(?m)([A-Z]{6}\d{11})", 3) ; (?m)([A-Z]{6}\d{11}) or (?m)([A-Z]{3}[A-Z]{3}\d{11})
    If @error = 1 Then
        ;MsgBox(0, 'DEBUG', 'There are no Inbound/Outbound SEA containers found. Trying 99M')
        $STATIC_TITLE[0] = 2
        Local $CONTAINER_LIST = []
        Local $CONTAINER_LIST = StringRegExp($CONTAINER_STRING, "(?m)([A-Z]{0}99M\d{18})", 3)
        If @error = 1 Then
            ;MsgBox(0, 'DEBUG', 'There are no 99M containers found. Trying 53')
            $STATIC_TITLE[0] = 3
            Local $CONTAINER_LIST = []
            Local $CONTAINER_LIST = StringRegExp($CONTAINER_STRING, "(?m)(\d{2}53\d{18})", 3)
        EndIf
    EndIf
    Local $CONTAINER = UBound($CONTAINER_LIST)
    Local $COUNTER = UBound($CONTAINER_LIST)
    Local $SPEED = 10000

Do
    For $i = 0 To UBound($CONTAINER_LIST) - 1
        If UBound($CONTAINER_LIST) > 0 Then
            Send($CONTAINER_LIST[$i])
            Send('{ENTER}')
            $COUNTER = $COUNTER -1
            ToolTip('Script is running. ' & $COUNTER & '/' & $CONTAINER & ' remaining.', 1, 1, $STATIC_TITLE[$STATIC_TITLE[0]])
            Sleep($SPEED)
            If UBound($CONTAINER_LIST) > 30 Then
            $SPEED = 5000
            ElseIf UBound($CONTAINER_LIST) < 30 Then
            $SPEED = 2500
            EndIf
        EndIf
    Next
Until $COUNTER <= 0

If UBound($CONTAINER_LIST) <> 0 Then
    MsgBox(0, 'Success!', 'All containers received. /!\ Verify /!\')
ElseIf UBound($CONTAINER_LIST) = 0 Then
    $STATIC_TITLE[0] = 4
    ToolTip('There are no containers in the clipboard.', 1, 1, $STATIC_TITLE[$STATIC_TITLE[0]])
EndIf
EndFunc

Func EXT()
    Exit
EndFunc
#EndRegion

While 1
Sleep(10)
WEnd

 

Link to comment
Share on other sites

It appears $message has no innertext to display, so question is does the span get populated at a particular time?  If I enter text manually it shows up fine, although I do have to allow Activex through (using local version of the page).

Link to comment
Share on other sites

Where is the InnerText from iWB2 Learner coming from then? Is it a different Obj? 
If so, then I just need to read that, and everything will be fine.

InnerText:
Container ID : LAXSEA18047120404 Unloaded successfully.

What happens is, when I input a container ID ( ex. LAXSEA18047120404 ), then a label is created at the top of the page that says:
Container ID : LAXSEA18047120404 Unloaded successfully. , or if it is invalid it will say Invalid Container ID. Initially this label is not there until you attempt to Unload Container.

Edited by FengHuangWuShen
Link to comment
Share on other sites

Np, I'm at work right now too, hoping to get this working tonight so I can use it while at work.

I'm running this after I click Unload Container, since the label is hidden until then.
Once the button is clicked, then it will be visible.

Edited by FengHuangWuShen
Link to comment
Share on other sites

It's still unable to get the Obj.

==> Variable must be of type "Object".:
MsgBox(0, 'DEBUG', $cLabel_Obj.innerText)
MsgBox(0, 'DEBUG', $cLabel_Obj^ ERROR

#include <IE.au3>
HotKeySet('{INS}', 'Test')

Local $IE = _IECreate('Https://***', 1, 1, 1, 1)
Local $User_Obj = _IEGetObjByName($IE, 'username')
Local $Pass_Obj = _IEGetObjByName($IE, 'userpassword')
Local $Submit_Obj = _IEGetObjByName($IE, 'submitbutton')
Local $Username = IniRead(@ScriptDir & '\Local Settings.ini', 'Auth', 'Username', Default)
Local $User_Input = _IEFormElementSetValue($User_Obj, $Username)
Local $Password = IniRead(@ScriptDir & '\Local Settings.ini', 'Auth', 'Password', Default)
Local $Pass_Input = _IEFormElementSetValue($Pass_Obj, $Password)
Global $Input_Speed = IniRead(@ScriptDir & 'Local Settings.ini', 'Options', 'Input Speed', Default)
_IEAction($Submit_Obj, 'click')

While 1
    Sleep($Input_Speed)
WEnd

Func Test()
    Local $cLabel_Obj = _IEGetObjById($IE, 'message')
    MsgBox(0, 'DEBUG', $cLabel_Obj.innerText)
EndFunc

 

Link to comment
Share on other sites

Even adding _IEAttach(), it still fails. Yet iWB2 Learner can find everything just fine...

 

Func Test()
    _IEAttach('Unload Container')
    Local $cLabel_Obj = _IEGetObjById($IE, 'message')
    MsgBox(0, 'DEBUG', $cLabel_Obj.innerText)
EndFunc

 

This seems to be the source for iWB2 Learner:

 

; https://autohotkey.com/board/topic/83238-broken-autohotkeynet-links-updated-5-22-2013/?p=530065
; Dragable Cursor is now Drawn In, rather than using external images
; Text Insert Point will not stay on edit control when clicked (unless highlighted)
; Updated to use New Realease of Sean's ComUtils

; To Do: Allow Text/HTML Pop-out for Viewing
; To Do: Make ChildNodes a complete tree
; Considering: Change from Click-to-Copy to Right-Click>>Copy Data

;{ ; CONSTANTS/PARAMETERS
    WM_ACTIVATE = 0x06
    WM_KILLFOCUS = 0x08
    WM_LBUTTONDOWN = 0x201
    WM_LBUTTONUP = 0x202
    Stored := object(   "AppName",      "iWB2 Learner"
                    ,   "TextLabel",    "InnerText"     ) ; hold stored/global values throughout script
;}
;{ ; DIRECTIVES
    #NoEnv
    #NoTrayIcon
    DetectHiddenWindows,on
    SetTitleMatchMode,slow  
    SetTitleMatchMode,2
;}
;{ ; AUTOEXEC
    ComObjError(false)
    OnMessage(WM_LBUTTONDOWN, "HandleMessage")
    OnExit, OnExitCleanup
    
    ; Main GUI
    Menu, Main, Add, Show Parent Structure, ParentStructure
    Gui, Menu, Main
    Gui, Add, Edit, x61 y5 w255 h20 hwndTitleHwnd vTitle HWNDh1,
    Gui, Add, Edit, x61 y30 w255 h20 vURLL HWNDh2,
    Gui, Add, Edit, x36 y55 w50 h20 vEleIndex HWNDh3, 
    Gui, Add, Edit, x120 y55 w90 h20 vEleName HWNDh4, 
    Gui, Add, Edit, x226 y55 w90 h20 vEleIDs HWNDh5, 
    Gui, Add, ListView, x6 y82 w310 h60 -LV0x10 AltSubmit vVarListView gSubListView NoSortHdr, % "Frame.#|index|name|id|"
    LV_ModifyCol(1, 65), LV_ModifyCol(2,49), LV_ModifyCol(3,87), LV_ModifyCol(4,87), LV_ModifyCol(2,"Center")
    Gui, Add, Edit, x11 y160 w302 h40 vhtml_text HWNDh6, 
    Gui, Add, Edit, x10 y217 w302 h40 vhtml_value HWNDh7, 
    Gui, Add, Text, x35 y7 w25 h20 +Center, Title
    Gui, Add, Text, x37 y33 w23 h20 +Center, Url
    Gui, Add, Text, x1 y56 w34 h20 +Center, Index
    Gui, Add, Text, x89 y57 w30 h21 +Center, Name
    Gui, Add, Text, x212 y58 w13 h20 +Center, ID
    Gui, Add, GroupBox, x6 y145 w310 h119 vText, InnerText
    Gui, Add, GroupBox, x6 y201 w310 h63 , OuterHTML
    
    ; CrossHair Control
    Gui, Add, Text, x5 y3 w25 h26 Border gCrossHair ReadOnly HWNDh8 Border
    CColor(h8, "White")
    Gui, Add, Text, x5 y3 w25 h4 HWNDh9 Border
    CColor(h9, "0046D5")
    Gui, Add, Text, x8 y17 w19 h1 Border vHBar
    Gui, Add, Text, x17 y8 w1 h19 Border vVBar
    Gui, Font, S6
    Gui, Add, Text, x1 y32 w35 h26 +Center, DRAG CURSOR
    
    Gui, +AlwaysOnTop +Delimiter`n
    Gui, Show, Center  h270 w322, % Stored.AppName
    Gui, +LastFoundExist
    WinSet, Redraw, , % "ahk_id" GuiWinHWND:=WinExist()
    ControlFocus, Static7, ahk_id %GuiWinHWND%

    ; Parental Structure GUI
    Gui 2: +ToolWindow +AlwaysOnTop +Resize
    Gui 2: Add, TreeView, vTView R17
    Gui 2: Show, Hide, Parent Structure
    WinGetPos, , , 2GuiW, 2GuiH, % "ahk_id"
    . Stored.2GUIhwnd := WinExist("Parent Structure ahk_class AutoHotkeyGUI")
    Menu, RClickMenu, Add ; Ensure RClickMenu Exists
    
    outline := Outline() ; create "Outline" object
    Hotkey, ~LButton Up, Off ; "~LButton Up" Hotkey only active when LButton is pressed
    return
;}

#s::
;{ ; Speak the Text of the Element
    ComObjCreate("SAPI.SpVoice").Speak(Stored.textOfObj)
    return
;}
~Lbutton Up::
;{ ; Handle LButton Being Released
    Hotkey, ~LButton Up, Off
    Lbutton_Pressed := False
    if IsObject(Stored.BColor) ; Restore Element Background Color
        Stored.BColor := ""
    else if Not CH { ; Reset CrossHair
        GuiControl, Show, HBar
        GuiControl, Show, VBar
        CrossHair(CH:=true)
    }
    RemoveFocus()
    return
;}  
HandleMessage( p_w, p_l, p_m, p_hw ) { ; Handle LButton Being Pressed (for "WM_LBUTTONDOWN")
    Gui, Submit, NoHide
    if (A_GuiControl = "VarListView") { ; Get Column Number - if clicked on ListView
        global column_num ; http://www.autohotkey.com/forum/viewtopic.php?t=6414
        VarSetCapacity( htinfo, 20 )
        , DllCall( "RtlFillMemory", "uint", &htinfo, "uint", 1, "uchar", p_l & 0xFF )
        , DllCall( "RtlFillMemory", "uint", &htinfo+1, "uint", 1, "uchar", ( p_l >> 8 ) & 0xFF )
        , DllCall( "RtlFillMemory", "uint", &htinfo+4, "uint", 1, "uchar", ( p_l >> 16 ) & 0xFF )
        , DllCall( "RtlFillMemory", "uint", &htinfo+5, "uint", 1, "uchar", ( p_l >> 24 ) & 0xFF )
        SendMessage, 0x1000+57, 0, &htinfo,, ahk_id %p_hw%
        If ( ErrorLevel = -1 )
            Return
        column_num := ( *( &htinfo+8 ) & 1 ) ? False : 1+*( &htinfo+16 )
    } 
    else if (%A_GuiControl% != "") {
            temp := clipboard := %A_GuiControl%
            ToolTip, % "clipboard= " (StrLen(temp) > 40 ? SubStr(temp,1,40) "..." : temp)
            SetTimer, RemoveToolTip, 1000
    }
    else if (A_GuiControl = "TView") { ; if clicked on TreeView (parent structure)
        Acc_ObjectFromPoint(child).accSelect(0x3, child)
        Hotkey, ~LButton Up, On
        global Stored
        if TV_GetParent(TVsel:=TV_GetSelection()) {
            TV_GetText(text, TVsel)
            RegExMatch(text, "\d+", child)
            clicked := Stored.pelt.childNodes[child]
        }
        else {
            clicked := Stored.pelt
            Loop, % TV_GetDiffCount(Stored.TVitem, TVsel)
                clicked := clicked.parentNode
        }
        Stored.BColor := BCobj(clicked, "silver")
    }
    RemoveFocus()
}
IE_HtmlElement() { ; get the parent windows & coord from the element    
    static IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}", IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
    CoordMode, Mouse
    MouseGetPos, xpos, ypos,, hCtl, 3
    WinGetClass, sClass, ahk_id %hCtl%
    If Not sClass == "Internet Explorer_Server"
        || Not pdoc := Query_Service(Acc_ObjectFromWindow(hCtl), IID_IHTMLWindow2).document
            Return
    global outline, Stored, Frame := object() ; store frames & hold "Frame" Coords & stored values
    pwin := Query_Service(pdoc , IID_IHTMLWindow2)
    , iWebBrowser2 := Query_Service(pwin,IID_IWebBrowserApp,IID_IWebBrowserApp)
    
    if pelt := pwin.document.elementFromPoint( xpos-xorg:=pwin.screenLeft, ypos-yorg:=pwin.screenTop ) {
        Stored.LV := object() ; hold frame info for ListView
        while (type:=pelt.tagName)="IFRAME" || type="FRAME" {
            selt .=   A_Index ") **[sourceIndex]=" pelt.sourceindex " **[Name]= " pelt.name " **[ID]= " pelt.id "`n"
            , Stored.LV[A_Index, "C1"] := type "." A_Index
            , Stored.LV[A_Index, "C2"] := pelt.sourceindex
            , Stored.LV[A_Index, "C3"] := pelt.name
            , Stored.LV[A_Index, "C4"] := pelt.id
            , Frame[A_Index] := pelt ; store frames
            , pwin :=   Query_Service(pbrt:=pelt.contentWindow, IID_IHTMLWindow2)
            , pdoc :=   pwin.document
            , Stored.LV[A_Index, "URL"] := pdoc.url
            , pbrt :=   pdoc.elementFromPoint(  xpos-xorg+=pelt.getBoundingClientRect().left
                                            ,   ypos-yorg+=pelt.getBoundingClientRect().top )
            , pelt :=   pbrt
        }
        pbrt :=   pelt.getBoundingClientRect()
        , l  :=   pbrt.left
        , t  :=   pbrt.top
        , r  :=   pbrt.right
        , b  :=   pbrt.bottom
        
        if Not outline.visible ; if the element has changed
            || (Stored.pelt.sourceIndex != pelt.sourceIndex) {
            ; (Stored["x1"] <> l+xorg || Stored["y1"] <> t+yorg || Stored["x2"] <> r+xorg || Stored["y2"] <> b+yorg) {
            if selt ; if the element is in a frame, get frame dimensions
                Frect := Frame[Frame.maxIndex()].getBoundingClientRect() ; get the Frame Rectangle
                , Frame.x1 := xorg ; set the frame Coordinates
                , Frame.y1 := yorg
                , Frame.x2 := FRect.right+xorg
                , Frame.y2 := FRect.bottom+yorg
            else, 
                Frame.x1:=Frame.y1:=Frame.x2:=Frame.y2:= "NA" ; if there isn't any frames, assign frame coords "NA"
            
            ; Change outline display
            outline.transparent(true)
            , outline.hide()            
            , coord := GetCoord(    Stored.x1 := l+xorg
                                ,   Stored.y1 := t+yorg
                                ,   Stored.x2 := r+xorg
                                ,   Stored.y2 := b+yorg
                                ,   iWebBrowser2.HWND   )
            , outline.show(coord.x1, coord.y1, coord.x2, coord.y2, coord.sides)
            , outline.setAbove( iWebBrowser2.HWND )
            , outline.transparent( false )  
        } 
    
        Sleep, 1 ; make sure Controls Update
        if (Stored.selt != selt) {
            LV_Delete()
            Loop, % Stored.LV.MaxIndex()
                LV_Add( ""  ,   Stored.LV[A_Index].C1
                            ,   Stored.LV[A_Index].C2
                            ,   Stored.LV[A_Index].C3
                            ,   Stored.LV[A_Index].C4   )
            Stored.selt := selt
        }
        Stored.pelt := pelt
        , Stored.LocationName := iWebBrowser2.LocationName
        , Stored.LocationURL := iWebBrowser2.LocationURL
        GoSub, UpdateGuiControls
        Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName ">"
    }
}

CrossHair: 
;{ ; allow dragable Cross-Hair when clicked
    if (A_GuiEvent = "Normal") {
        SetBatchLines, -1
        Hotkey, ~LButton Up, On
        { ; Set CrossHair Cursor & Hide in GUI
            GuiControl, Hide, HBar
            GuiControl, Hide, VBar
            CrossHair(CH:=false)
        }
        Lbutton_Pressed := True
        while, Lbutton_Pressed
            IE_HtmlElement()
        outline.hide()
        if Stored.pelt.tagName != ""
            Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName "> [" GetTagIndex(Stored.pelt) "]"
        if WinVisible("ahk_id" Stored.2GUIhwnd)
            GoSub, ParentStructure
        SetBatchLines, 10ms
    }
    return
;}
OnExitCleanup:
;{ ; Cleanup when the Script Exits
    CrossHair(true)
    GuiClose:
        ExitApp
;}
UpdateGuiControls:
;{ ; Update the Main GUI with the New Element Info
    SetBatchLines, -1
    Gui, 1: Default
    textOfObj := inpt(Stored.pelt)
    GuiControl, , Title, % Stored.LocationName
    GuiControl, , URLL, % Stored.LocationURL ; Edit2
    GuiControl, , EleIndex, % Stored.pelt.sourceindex ; Edit3
    GuiControl, , EleName, % Stored.pelt.name ; Edit4
    GuiControl, , EleIDs, % Stored.pelt.id ; Edit5
    if (Stored.textOfObj != textOfObj) 
        GuiControl, , html_text, % Stored.textOfObj:=textOfObj ; Edit6
    if (Stored.outerHTML != (val:=Stored.pelt.outerHTML) ) 
        GuiControl, , html_value, % Stored.outerHTML:=val ; Edit7
    textOfObj:=val:=""
    RemoveFocus()
;}
SubListView:
;{ ; When the Frames ListView is clicked
    if (A_GuiEvent = "Normal") { ; if Right Clicked
        if (column_num = 1)
            LVselection := Stored.LV[A_EventInfo].url
        else,
            LV_GetText(LVselection, A_EventInfo, column_num)
        if LVselection { ; if listview item contains data
            clipboard := LVSelection
            ToolTip, % "clipboard= " (StrLen(LVSelection) > 40 ? SubStr(LVSelection,1,40) "..." : LVSelection)
            SetTimer, RemoveToolTip, 1000
        }
    }
    Return
;}
RemoveToolTip:
;{
    SetTimer, RemoveToolTip, off
    ToolTip
    return
;}
ParentStructure:
;{ ; "Parent Structure" Menu Item Labels
    ;{
        SetBatchLines, -1
        if Not Stored.pelt.tagName
            return
        nodes := object()
        elem := Stored.pelt
        Gui 2: Default
        TV_Delete()
        Loop {
            if A_Index != 1
                elem := elem.parentNode
            nodes.insert( 1, elem.tagName
                    .   (elem.id!=""? " id= """ elem.id """":"")
                    .   (elem.name!=""? "  name= """ elem.name """":"") )
        } Until, elem.tagName = "html"

        GuiControl, -Redraw, TView
        For, Each, item in nodes
            Stored.TVitem := TV_Add(item)
        
        nodes := Stored.pelt.childNodes
        Loop, % nodes.length {
            elem := nodes.item(A_Index-1)
            TV_Add("[" A_Index-1 "] " elem.tagName
                .   (elem.id!=""? " id= """ elem.id """":"")
                .   (elem.name!=""? "  name= """ elem.name """":"")
            , Stored.TVitem )
        }
        nodes:=elem:=""
        GuiControl, +Redraw, TView
        TV_Modify(Stored.TVitem, "Select Bold")
        if Not WinVisible("ahk_id" Stored.2GUIhwnd) {
            WinGetPos, x, y, w, , ahk_id %GuiWinHWND%
            WinMove, % "ahk_id" Stored.2GUIhwnd,
                , (x+w+2GuiW > A_ScreenWidth? x-2GuiW-5:x+w+5)
                , %y%, %2GuiW%, %2GuiH%
            WinShow, % "ahk_id" Stored.2GUIhwnd
            temp:=""
        }
        return
    ;}
    2GuiClose:
    ;{
        Gui 2: Hide
        Gui 1: Default
        Stored.TVitem := ""
        return
    ;}
    2GuiSize:
    ;{
        Anchor(TView, "wh")
        return
    ;}
    2GuiContextMenu:
    ;{
        if (A_GuiControl = "TView") {
            Acc_ObjectFromPoint(child).accSelect(0x3, child)
            Menu, RClickMenu, DeleteAll
            TV_GetText(text, TV_GetSelection())
            if RegExMatch(text, "id= ""\K[^""]+", ElemID)
                Menu, RClickMenu, Add, Copy ID, RClick
            if RegExMatch(text, "name= ""\K[^""]+", ElemName)
                Menu, RClickMenu, Add, Copy Name, RClick
            Menu, RClickMenu, Add, Use Element, RClick
            Menu, RClickMenu, Show
        }
        return
    ;}
    RClick:
    ;{
        Gui, 2: +OwnDialogs
        if (A_ThisMenuItem = "Copy ID")
            clipboard := ElemID
        else if (A_ThisMenuItem = "Copy Name")
            clipboard := ElemName
        else if (A_ThisMenuItem = "Use Element") {
            temp := Stored.pelt
            Gui, 2: Default
            if TV_GetParent(TVsel:=TV_GetSelection()) {
                TV_GetText(text, TVsel)
                RegExMatch(text, "\d+", child)
                Stored.pelt := Stored.pelt.childNodes[child]
            }
            else,
                Loop, % TV_GetDiffCount(Stored.TVitem, TVsel)
                    Stored.pelt := Stored.pelt.parentNode
            if Not Stored.pelt.sourceIndex {
                MsgBox, 262160, Selection Error, Cannot access this element.
                Stored.pelt := temp
            }
            else {
                Gui, 1: Default
                Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName ">"
                    . (Stored.pelt.tagName="HTML"? "":" [" GetTagIndex(Stored.pelt) "]")
                GoSub, UpdateGuiControls
                if WinVisible("ahk_id" Stored.2GUIhwnd)
                    GoSub, ParentStructure
            }
        }   
        ElemName:=ElemID:=TVsel:=child:=temp:=""
        return
    ;}
;}

;{ ; OUTLINE OBJECT DEFINITION
Outline(color="red") { ; uses GUI 95-99
    self := object( "base", object( "show",         "Outline_Show"
                                ,   "hide",         "Outline_Hide" 
                                ,   "setAbove",     "Outline_SetAbove"  
                                ,   "transparent",  "Outline_Transparent"
                                ,   "color",        "Outline_Color"
                                ,   "destroy",      "Outline_Destroy"
                                ,   "__delete",     "Object_Delete" )   )
    Loop, 4 {
        Gui, % A_Index+95 ": -Caption +ToolWindow"
        Gui, % A_Index+95 ": Color", %color%
        Gui, % A_Index+95 ": Show", NA h0 w0, outline%A_Index%
        self[A_Index] := WinExist("outline" A_Index " ahk_class AutoHotkeyGUI")
    }
    self.visible := false
    , self.color := color
    , self.top := self[1]
    , self.right := self[2]
    , self.bottom := self[3]
    , self.left := self[4]
    Return, self
}
    Outline_Show(self, x1, y1, x2, y2, sides="TRBL") { ; show outline at coords
        if InStr( sides, "T" )
            Gui, 96:Show, % "NA X" x1-2 " Y" y1-2 " W" x2-x1+4 " H" 2,outline1
        Else, Gui, 96: Hide
        if InStr( sides, "R" )
            Gui, 97:Show, % "NA X" x2 " Y" y1 " W" 2 " H" y2-y1,outline2
        Else, Gui, 97: Hide
        if InStr( sides, "B" )
            Gui, 98:Show, % "NA X" x1-2 " Y" y2 " W" x2-x1+4 " H" 2,outline3
        Else, Gui, 98: Hide
        if InStr( sides, "L" )
            Gui, 99:Show, % "NA X" x1-2 " Y" y1 " W" 2 " H" y2-y1,outline4
        Else, Gui, 99: Hide
        self.visible := true        
    }
    Outline_Hide(self) { ; hide outline
        Loop, 4
            Gui, % A_Index+95 ": Hide"
        self.visible := false
    }
    Outline_SetAbove(self, hwnd) { ; set Z-Order one above "hwnd"
        ABOVE := DllCall("GetWindow", "uint", hwnd, "uint", 0x3) ; get window directly above "hwnd"
        Loop, 4  ; set 4 "outline" GUI's directly below "hwnd_above"
            DllCall(    "SetWindowPos", "uint", self[ A_Index ], "uint", ABOVE
                    ,   "int", 0, "int", 0, "int", 0, "int", 0
                    ,   "uint", 0x1|0x2|0x10    ) ; NOSIZE | NOMOVE | NOACTIVATE
    }
    Outline_Transparent(self, param) { ; set Transparent ( different from hiding )
        Loop, 4
            WinSet, Transparent, % param=1? 0:255, % "ahk_id" self[A_Index]
        self.visible := !param
    }
    Outline_Color(self, color) { ; set Color of Outline GUIs
        Loop, 4
            Gui, % A_Index+95 ": Color" , %color%
        self.color := color
    }
    Outline_Destroy(self) { ; Destroy Outline
        VarSetCapacity(self, 0)
    }
    Object_Delete() { ; Destroy "outline GUIs" when object is deleted
        Loop, 4
            Gui, % A_Index+95 ": Destroy"
    }
;}

; OTHER FUNCTIONS
CrossHair(OnOff=1) {  ; Change Cursor to Cross-Hair
    ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
    static AndMask, XorMask, $, h_cursor, IDC_CROSS := 32515
        ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
        , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
        , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
    if (OnOff = "Init" or OnOff = "I" or $ = "") {      ; init when requested or at first call
        $ := "h"                                          ; active default cursors
        , VarSetCapacity( h_cursor,4444, 1 )
        , VarSetCapacity( AndMask, 32*4, 0xFF )
        , VarSetCapacity( XorMask, 32*4, 0 )
        , system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650"
        StringSplit c, system_cursors, `,
        Loop, %c0%
            h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
            , h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
            , b%A_Index% := DllCall("LoadCursor", "Uint", "", "Int", IDC_CROSS, "Uint")
    }
    $ := (OnOff = 0 || OnOff = "Off" || $ = "h" && (OnOff < 0 || OnOff = "Toggle" || OnOff = "T")) ? "b" : "h"

    Loop, %c0%
        h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
        , DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
; http://www.autohotkey.com/docs/commands/DllCall.htm
; http://www.autohotkey.com/forum/topic4570.html#75609
}
inpt(i) { ; return the Text of the Element
    global Stored
    tag :=  i.tagName
    if tag in BUTTON,INPUT,OPTION,SELECT,TEXTAREA
    {
        if (Stored.TextLabel = "InnerText")
            GuiControl, , Text, % Stored.TextLabel:="Value"
        return, i.value
    }
    if (Stored.TextLabel = "Value")
        GuiControl, , Text, % Stored.TextLabel:="InnerText"
    return, i.innerText
}

GetCoord( x1,y1,x2,y2, WinHWND ) { ; get the coordinates for the outline
    global Frame, outline
    WinGetPos, Wx, Wy, , , ahk_id %WinHWND%
    ControlGetPos, Cx1, Cy1, Cw, Ch, Internet Explorer_Server1, ahk_id %WinHWND%
    Cx1+=Wx  ; set "Internet Explorer_Server1" dimensions
    , Cy1+=Wy
    , Cx2:=Cx1+Cw
    , Cy2:=Cy1+Ch
    
    ; Example return: object( "x1", 150, "y1", 200, "x2", 250, "y2", 300, "sides", "TRBL" )
    Return, object( "x1",       Value( x1,Cx1,Frame["x1"], ">" )
                ,   "y1",       Value( y1,Cy1,Frame["y1"], ">" )
                ,   "x2",       Value( x2,Cx2,Frame["x2"], "<" )
                ,   "y2",       Value( y2,Cy2,Frame["y2"], "<" )
                ,   "sides",    ( ElemCoord( y1,Cy1,Frame["y1"], ">" ) ? "T" : "" )
                            .   ( ElemCoord( x2,Cx2,Frame["x2"], "<" ) ? "R" : "" )
                            .   ( ElemCoord( y2,Cy2,Frame["y2"], "<" ) ? "B" : "" )
                            .   ( ElemCoord( x1,Cx1,Frame["x1"], ">" ) ? "L" : "" ) )
}
Value( E,C,F, option=">" ) { ; returns the value of the Greatest (or smallest) value
    return, F+0=""? (option=">"? (E>=C? E:C) : (E<=C? E:C))
        :   (option=">"? (E>=C? (E>=F? E:F) : (C>=F? C:F)) : (E<=C? (E<=F? E:F) : (C<=F? C:F)))
}
ElemCoord( E,C,F, option=">" ) { ; returns true if the Element value is the Greatest (or smallest)
    return, F+0=""? (option=">"? (E>=C? 1:0):(E<=C? 1:0))
        :   (option=">"? (E>=C && E>=F? 1:0):(E<=C && E<=F? 1:0))
}

GetTagIndex(element) { ; return the Index in the Tag Collection
    if IsMemberOf(element, "sourceIndex")
    and (index:=element.sourceIndex)
    and (tags:=element.ownerDocument.all.tags(element.tagName))
    and (top:=tags.length, bottom:=0)
        Loop {
            test := Floor( (top+bottom)/2 )
            i := tags[test].sourceIndex
            if (index < i)
                top := test
            else if (index > i)
                bottom := test
            else,
                return, test
        }
}
IsMemberOf(obj, name) { ; http://www.autohotkey.com/forum/topic63827.html
   return,  DllCall(NumGet(NumGet(1*p:=ComObjUnwrap(obj))+A_PtrSize*5)
        ,   "Ptr",  p
        ,   "Ptr",  VarSetCapacity(iid,16,0)*0+&iid
        ,   "Ptr*", &name
        ,   "UInt", 1
        ,   "UInt", 1024
        ,   "Int*", dispID)=0
        && dispID+1, ObjRelease(p)
}
TV_GetDiffCount(p1, p2) {
    count = 0
    while, p1 != p2
        p1 := TV_GetPrev(p1)
        , count++
    return, count
}
WinVisible(WinTitle) {
    temp := A_DetectHiddenWindows
    DetectHiddenWindows, Off
    out := WinExist(WinTitle)
    DetectHiddenWindows, %temp%
    return, out
}
BCobj(elem, color) { ; highlight Element Background
    static  base := object("__delete","BCobj_Delete")
    return, object("elem",elem, "color",elem.style.backgroundColor, "base",base)
        ,   elem.style.backgroundColor := color
}
BCobj_Delete(self) {
    self.elem.style.backgroundColor := self.color
}
RemoveFocus() { ; Handle LButton Being Release over Main GUI
    global GuiWinHWND
    ControlGetFocus, focus, ahk_id %GuiWinHWND%
    if (SubStr(focus,1,4) == "Edit") {
        ControlGet, text, Selected, , %focus%, ahk_id %GuiWinHWND%
        if Not text
            ControlFocus, Static7, ahk_id %GuiWinHWND%
    }
}

CColor(Hwnd, Background="", Foreground="") {
    ; http://www.autohotkey.com/forum/viewtopic.php?t=39055
    return CColor_(Background, Foreground, "", Hwnd+0)
}
CColor_(Wp, Lp, Msg, Hwnd) {
    static
    static WM_CTLCOLOREDIT=0x0133, WM_CTLCOLORLISTBOX=0x134, WM_CTLCOLORSTATIC=0x0138
        ,LVM_SETBKCOLOR=0x1001, LVM_SETTEXTCOLOR=0x1024, LVM_SETTEXTBKCOLOR=0x1026, TVM_SETTEXTCOLOR=0x111E, TVM_SETBKCOLOR=0x111D
        ,BS_CHECKBOX=2, BS_RADIOBUTTON=8, ES_READONLY=0x800
        ,CLR_NONE=-1, CSILVER=0xC0C0C0, CGRAY=0x808080, CWHITE=0xFFFFFF, CMAROON=0x80, CRED=0x0FF, CPURPLE=0x800080, CFUCHSIA=0xFF00FF,CGREEN=0x8000, CLIME=0xFF00, COLIVE=0x8080, CYELLOW=0xFFFF, CNAVY=0x800000, CBLUE=0xFF0000, CTEAL=0x808000, CAQUA=0xFFFF00
        ,CLASSES := "Button,ComboBox,Edit,ListBox,Static,RICHEDIT50W,SysListView32,SysTreeView32"
   
    If (Msg = "") {     
        if !adrSetTextColor
            adrSetTextColor   := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetTextColor")
            ,adrSetBkColor   := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkColor")
            ,adrSetBkMode   := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkMode")
   
        ;Set the colors (RGB -> BGR)
        BG := !Wp ? "" : C%Wp% != "" ? C%Wp% : "0x" SubStr(WP,5,2) SubStr(WP,3,2) SubStr(WP,1,2)
        FG := !Lp ? "" : C%Lp% != "" ? C%Lp% : "0x" SubStr(LP,5,2) SubStr(LP,3,2) SubStr(LP,1,2)

        ;Activate message handling with OnMessage() on the first call for a class
        WinGetClass, class, ahk_id %Hwnd%
        If class not in %CLASSES%
            return A_ThisFunc "> Unsupported control class: " class

        ControlGet, style, Style, , , ahk_id %Hwnd%
        if (class = "Edit") && (Style & ES_READONLY)
            class := "Static"
   
        if (class = "Button")
            if (style & BS_RADIOBUTTON) || (style & BS_CHECKBOX)
                class := "Static"
            else return A_ThisFunc "> Unsupported control class: " class
      
        if (class = "ComboBox") {
            VarSetCapacity(CBBINFO, 52, 0), NumPut(52, CBBINFO), DllCall("GetComboBoxInfo", "UInt", Hwnd, "UInt", &CBBINFO)
            hwnd := NumGet(CBBINFO, 48)      ;hwndList
            %hwnd%BG := BG, %hwnd%FG := FG, %hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : -1

            IfEqual, CTLCOLORLISTBOX,,SetEnv, CTLCOLORLISTBOX, % OnMessage(WM_CTLCOLORLISTBOX, A_ThisFunc)

            If NumGet(CBBINFO,44)   ;hwndEdit
                Hwnd :=  Numget(CBBINFO,44), class := "Edit"
        }

        if class in SysListView32,SysTreeView32
        {
             m := class="SysListView32" ? "LVM" : "TVM"
             SendMessage, %m%_SETBKCOLOR, ,BG, ,ahk_id %Hwnd%
             SendMessage, %m%_SETTEXTCOLOR, ,FG, ,ahk_id %Hwnd%
             SendMessage, %m%_SETTEXTBKCOLOR, ,CLR_NONE, ,ahk_id %Hwnd%
             return
        }

        if (class = "RICHEDIT50W")
            return f := "RichEdit_SetBgColor", %f%(Hwnd, -BG)

        if (!CTLCOLOR%Class%)
            CTLCOLOR%Class% := OnMessage(WM_CTLCOLOR%Class%, A_ThisFunc)

        return %Hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : CLR_NONE,  %Hwnd%BG := BG,  %Hwnd%FG := FG
    }
 
    ; Message handler
    critical               ;its OK, always in new thread.

    Hwnd := Lp + 0, hDC := Wp + 0
    If (%Hwnd%) {
    DllCall(adrSetBkMode, "uint", hDC, "int", 1)
    if (%Hwnd%FG)
        DllCall(adrSetTextColor, "UInt", hDC, "UInt", %Hwnd%FG)
    if (%Hwnd%BG)
        DllCall(adrSetBkColor, "UInt", hDC, "UInt", %Hwnd%BG)
    return (%Hwnd%)
    }
}


;------------------------------------------------------------------------------
; Acc.ahk Standard Library
; by Sean
; Updated by jethrow:
;   Modified ComObjEnwrap params from (9,pacc) --> (9,pacc,1)
;   Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
;   Added Acc_GetRoleText & Acc_GetStateText
;   Added additional functions - commented below
;   Removed original Acc_Children function
;   Added Acc_Error, Acc_ChildrenByRole, & Acc_Get functions
; last updated 10/25/2012
;------------------------------------------------------------------------------

Acc_Init()
{
    Static  h
    If Not  h
        h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
}
Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
{
    Acc_Init()
    If  DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
    Return  ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")
{
    Acc_Init()
    If  DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
    Return  ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}

Acc_ObjectFromWindow(hWnd, idObject = 0)
{
    Acc_Init()
    If  DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
    Return  ComObjEnwrap(9,pacc,1)
}

Acc_WindowFromObject(pacc)
{
    If  DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0
    Return  hWnd
}

Acc_GetRoleText(nRole)
{
    nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0)
    VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
    DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1)
    Return  sRole
}

Acc_GetStateText(nState)
{
    nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0)
    VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
    DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1)
    Return  sState
}

Acc_SetWinEventHook(eventMin, eventMax, pCallback)
{
    Return  DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", 0, "Ptr", pCallback, "Uint", 0, "Uint", 0, "Uint", 0)
}

Acc_UnhookWinEvent(hHook)
{
    Return  DllCall("UnhookWinEvent", "Ptr", hHook)
}
/*  Win Events:

    pCallback := RegisterCallback("WinEventProc")
    WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime)
    {
        Critical
        Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild)
        ; Code Here:

    }
*/

; Written by jethrow
Acc_Role(Acc, ChildId=0) {
    try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object"
}
Acc_State(Acc, ChildId=0) {
    try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object"
}
Acc_Location(Acc, ChildId=0, byref Position="") { ; adapted from Sean's code
    try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
    catch
        return
    Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
    return  {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")}
}
Acc_Parent(Acc) { 
    try parent:=Acc.accParent
    return parent?Acc_Query(parent):
}
Acc_Child(Acc, ChildId=0) {
    try child:=Acc.accChild(ChildId)
    return child?Acc_Query(child):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
    try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
Acc_Error(p="") {
    static setting:=0
    return p=""?setting:setting:=p
}
Acc_Children(Acc) {
    if ComObjType(Acc,"Name") != "IAccessible"
        ErrorLevel := "Invalid IAccessible Object"
    else {
        Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
        if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
            Loop %cChildren%
                i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
            return Children.MaxIndex()?Children:
        } else
            ErrorLevel := "AccessibleChildren DllCall Failed"
    }
    if Acc_Error()
        throw Exception(ErrorLevel,-1)
}
Acc_ChildrenByRole(Acc, Role) {
    if ComObjType(Acc,"Name")!="IAccessible"
        ErrorLevel := "Invalid IAccessible Object"
    else {
        Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
        if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
            Loop %cChildren% {
                i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
                if NumGet(varChildren,i-8)=9
                    AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
                else
                    Acc_Role(Acc, child)=Role?Children.Insert(child):
            }
            return Children.MaxIndex()?Children:, ErrorLevel:=0
        } else
            ErrorLevel := "AccessibleChildren DllCall Failed"
    }
    if Acc_Error()
        throw Exception(ErrorLevel,-1)
}
Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
    static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"}
    AccObj :=   IsObject(WinTitle)? WinTitle
            :   Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
    if ComObjType(AccObj, "Name") != "IAccessible"
        ErrorLevel := "Could not access an IAccessible Object"
    else {
        StringReplace, ChildPath, ChildPath, _, %A_Space%, All
        AccError:=Acc_Error(), Acc_Error(true)
        Loop Parse, ChildPath, ., %A_Space%
            try {
                if A_LoopField is digit
                    Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic "m2" output in else-statement
                else
                    RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
                if Not Children.HasKey(m2)
                    throw
                AccObj := Children[m2]
            } catch {
                ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, Acc_Error(AccError)
                if Acc_Error()
                    throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField)
                return
            }
        Acc_Error(AccError)
        StringReplace, Cmd, Cmd, %A_Space%, , All
        properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
        try {
            if (Cmd = "Location")
                AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
              , ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
            else if (Cmd = "Object")
                ret_val := AccObj
            else if Cmd in Role,State
                ret_val := Acc_%Cmd%(AccObj, ChildID+0)
            else if Cmd in ChildCount,Selection,Focus
                ret_val := AccObj["acc" Cmd]
            else
                ret_val := AccObj["acc" Cmd](ChildID+0)
        } catch {
            ErrorLevel := """" Cmd """ Cmd Not Implemented"
            if Acc_Error()
                throw Exception("Cmd Not Implemented", -1, Cmd)
            return
        }
        return ret_val, ErrorLevel:=0
    }
    if Acc_Error()
        throw Exception(ErrorLevel,-1)
}


; https://github.com/shajul/Autohotkey/blob/master/DotNet/Lib/Query.ahk
;------------------------------------------------------------------------------
; Query.ahk Standard Library
; by Sean
;
; REQUIREMENT: 32/64-bit UNICODE AutoHotkey_L
;------------------------------------------------------------------------------

Query_Service(pobj, SID, IID = "!", bRaw = "")
{
    If  DllCall(NumGet(NumGet(0,IsObject(pobj)?pobj:=ComObjUnwrap(pobj):pobj)), "Ptr", pobj, "Ptr", -VarSetCapacity(PID,16)+NumPut(0xFA096000AA003480,NumPut(0x11CE74366D5140C1,PID,"UInt64"),"UInt64"), "Ptr*", psp)=0
    &&  DllCall(NumGet(NumGet(0,psp),A_PtrSize*3), "Ptr", psp, "Ptr", Query_Guid4String(SID,SID), "Ptr", IID=="!"?&SID:Query_Guid4String(IID,IID), "Ptr*", pobj:=0)+DllCall(NumGet(NumGet(0,psp),A_PtrSize*2), "Ptr", psp)*0=0
    Return  bRaw?pobj:ComObjEnwrap(9,pobj)
}

Query_Interface(pobj, IID = "", bRaw = "")
{
    If  DllCall(NumGet(NumGet(0,IsObject(pobj)?pobj:=ComObjUnwrap(pobj):pobj)), "Ptr", pobj+0, "Ptr", Query_Guid4String(IID,IID), "Ptr*", pobj:=0)=0
    Return  bRaw?pobj:ComObjEnwrap(9,pobj)
}

Query_Guid4String(ByRef GUID, sz = "")
{
    Return  DllCall("ole32\CLSIDFromString", "WStr", sz?sz:sz==""?"{00020400-0000-0000-C000-000000000046}":"{00000000-0000-0000-C000-000000000046}", "Ptr", VarSetCapacity(GUID,16,0)*0+&GUID)*0+&GUID
}


; https://autohotkey.com/board/topic/91997-gui-anchor-for-current-version-of-ahk/#entry580170
Anchor(i, a := "", r := false) {
    static c, cs := 12, cx := 255, cl := 0, g, gs := 8, gl := 0, gpi, gw, gh, z := 0, k := 0xffff, ptr
    if z = 0
        VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), ptr := A_PtrSize ? "Ptr" : "UInt", z := true
    if !WinExist("ahk_id" . i) {
        GuiControlGet t, Hwnd, %i%
        if ErrorLevel = 0
            i := t
        else ControlGet i, Hwnd,, %i%
    }
    VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), ptr, &gi)
        , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int")
    if (gp != gpi) {
        gpi := gp
        loop %gl%
            if NumGet(g, cb := gs * (A_Index - 1), "UInt") == gp {
                gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1
                break
            }
        if !gf
            NumPut(gp, g, gl, "UInt"), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs
    }
    ControlGetPos dx, dy, dw, dh,, ahk_id %i%
    loop %cl%
        if NumGet(c, cb := cs * (A_Index - 1), "UInt") == i {
            if (a = "") {
                cf := 1
                break
            }
            giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short")
                , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short")
            loop Parse, a, xywh
                if A_Index > 1
                    av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField)
                        , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1)
            DllCall("SetWindowPos", "UInt", i, "UInt", 0, "Int", dx, "Int", dy
                , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4)
            if r != 0
                DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101) ; RDW_UPDATENOW | RDW_INVALIDATE
            return
        }
    if cf != 1
        cb := cl, cl += cs
    bx := NumGet(gi, 48, "UInt"), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52, "UInt")
    if cf = 1
        dw -= giw - gw, dh -= gih - gh
    NumPut(i, c, cb, "UInt"), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short")
        , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short")
    return true
}

Query_String4Guid(pGUID)
{
    Return  DllCall("ole32\StringFromGUID2", "Ptr", pGUID, "WStr", sz:="{00000000-0000-0000-0000-000000000000}", "Int", 39)?sz:""
}

 

Edited by FengHuangWuShen
Link to comment
Share on other sites

Tried a different way... still failed. Why is this so difficult to accomplish... any help please?

Since using iWB2 Learner says that it is a FRAME.1, I figured I would try _IEFrameGetObjByName(), which I found on another post, but it's still not working.

Ref:

Func Test()
    Local $IE = _IEAttach('Oracle Logistics')
    Local $IE_Frame = _IEFrameGetObjByName($IE, 'mainBody')
    ;Local $cLabel_Obj = _IEGetObjById($IE, 'message')
    ;MsgBox(0, 'DEBUG', $cLabel_Obj.innerText)
    Local $Container_Obj = _IEFormGetObjByName($IE, 'containerId')
    Local $Container_Input = _IEFormElementSetValue($Container_Obj, 'Test')
EndFunc

 

Link to comment
Share on other sites

Me and Subz have been discussing the problem throughout this thread, so I guess you haven't read everything? Not to be rude, but the problem seems very clear to me.

I'm trying to read data from an object in an IE window, but for some reason nothing can find it. But if I use iWB2 Learner, it finds it just fine. So the question is, why is nothing working as it should work...

Full code:

#include <IE.au3>
HotKeySet('{INS}', 'Test')
HotKeySet('{END}', 'EXT')

Global $IE = _IECreate('https://*')
Local $User_Obj = _IEGetObjByName($IE, 'username')
Local $Pass_Obj = _IEGetObjByName($IE, 'userpassword')
Local $Submit_Obj = _IEGetObjByName($IE, 'submitbutton')
Local $Username = IniRead(@ScriptDir & '\Local Settings.ini', 'Auth', 'Username', Default)
Local $User_Input = _IEFormElementSetValue($User_Obj, $Username)
Local $Password = IniRead(@ScriptDir & '\Local Settings.ini', 'Auth', 'Password', Default)
Local $Pass_Input = _IEFormElementSetValue($Pass_Obj, $Password)
Global $Input_Speed = IniRead(@ScriptDir & 'Local Settings.ini', 'Options', 'Input Speed', Default)
_IEAction($Submit_Obj, 'click')

While 1
    Sleep($Input_Speed)
WEnd

Func Test()
    Local $IE = _IEAttach('Shipment Search')
    Local $IE_Frame = _IEFrameGetObjByName($IE, 'mainBody')
    ;Local $cLabel_Obj = _IEGetObjById($IE, 'message')
    ;MsgBox(0, 'DEBUG', $cLabel_Obj.innerText)
    Local $Container_Obj = _IEFormGetObjByName($IE, 'containerId')
    Local $Container_Input = _IEFormElementSetValue($Container_Obj, 'Test')
EndFunc

Func EXT()
    Exit
EndFunc



Simply reading an object on the login page of our companies website works fine, I can automate the login, and click the buttons, but as soon as I proceed to any of the pages inside this website, it's as if IE creates a frame, and all objects are inside this frame ( as per iWB2 Learner, it says the object is in FRAME.1, frame Obj name = mainBody, id = containerId, name = containerId )

The error output is this:

 

--> IE.au3 T3.0-2 Warning from function _IEFormGetObjByName, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

 

Edited by FengHuangWuShen
Edit
Link to comment
Share on other sites

&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('topbar', {'source':'/GC3/glog.webserver.problem.CheckProblemServlet/nss?ct=1966607226'})); 

 

TMPage.PAGE.bufferComponent( new TMUIPanelSplitterComponent('gc3Layout:ps3', {'orientation':'horizontal','splitterPosition':185, 'positionedFromEnd':false,'collapsed':false })); 


&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('sidebar', {'source':'/GC3/glog.webserver.usermenu.ViewUserMenuServlet/nss?ct=1966607226&full=y'})); 

 


&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('body', {'source':'/GC3/glog.webserver.util.BodyServlet/nss?ct=1966607226'})); 
&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('topbar', {'source':'/GC3/glog.webserver.problem.CheckProblemServlet/nss?ct=1966607226'})); 
&nbsp;
 
 
TMPage.PAGE.bufferComponent( new TMUIPanelSplitterComponent('gc3Layout:ps3', {'orientation':'horizontal','splitterPosition':185, 'positionedFromEnd':false,'collapsed':false })); 


&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('sidebar', {'source':'/GC3/glog.webserver.usermenu.ViewUserMenuServlet/nss?ct=1966607226&full=y'})); 

 


&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('body', {'source':'/GC3/glog.webserver.util.BodyServlet/nss?ct=1966607226'})); 

&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('sidebar', {'source':'/GC3/glog.webserver.usermenu.ViewUserMenuServlet/nss?ct=1966607226&full=y'})); 

 


&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('body', {'source':'/GC3/glog.webserver.util.BodyServlet/nss?ct=1966607226'})); 
&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('sidebar', {'source':'/GC3/glog.webserver.usermenu.ViewUserMenuServlet/nss?ct=1966607226&full=y'})); 
&nbsp;
 
 
&nbsp;
TMPage.PAGE.bufferComponent(new TMUIInlineFrameComponent('body', {'source':'/GC3/glog.webserver.util.BodyServlet/nss?ct=1966607226'})); 
&nbsp;

 

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...