Jump to content

I need help sending html to an object


Recommended Posts

This is going to be lengthy but I am going to provide as much information as possible.

I am writing a script to automate some repetitive tasks for myself. Our ticketing system runs through IE and VMware. I had issues getting it to attach to IE at first so I just developed it to work off of TAB commands. So when you start a script, you have to make sure your cursor starts in the right field. This works for me because I built it and can work around its quirks. However, my boss has seen the tool and wants to roll it out to everyone on our team which is roughly 80 people. So I want to make it more reliable and user friendly and I think the best way to do that is to have the script target the specific fields instead of relying to tabbing through fields.

 

I started digging through the ie.au3 documentation and I did finally get it to attach.

And most fields I was able to locate with a script that highlighted and mapped the fields. Except for 2 and these are the most important fields.

These fields are html editor type fields. I have attached a picture of said field for understanding.

Here is the code for the object I want to edit. And this is the code I get when I read the outerhtml with ie.au3:

<OBJECT tabIndex=1 id=EXTFLDV_500517_HTML_EDITOR class=RichText name=EXTFLDV_500517_HTML_EDITOR classid=clsid:633D2265-5264-4D33-BF2A-7D7A6B38201A iwpropid="id" iwpropmandatory="ismMandatory" iwpropconditionalmandatory="ismConditionalMandatory" iwpropmandatoryon="ismMandatoryOn" iwpropconditionalmandatoryon="ismConditionalMandatoryOn" iwpropreadonly="ismReadOnly" ismMandatoryOn="false" ismMandatory="false" ismConditionalMandatoryOn="false" isLoading="false">
<PARAM NAME="Visible" VALUE="-1">
<PARAM NAME="AutoScroll" VALUE="0">
<PARAM NAME="AutoSize" VALUE="0">
<PARAM NAME="AxBorderStyle" VALUE="1">
<PARAM NAME="Caption" VALUE="">
<PARAM NAME="Font" VALUE="Tahoma">
<PARAM NAME="KeyPreview" VALUE="0">
<PARAM NAME="PixelsPerInch" VALUE="96">
<PARAM NAME="PrintScale" VALUE="1">
<PARAM NAME="Scaled" VALUE="-1">
<PARAM NAME="DropTarget" VALUE="0">
<PARAM NAME="HelpFile" VALUE="">
<PARAM NAME="PopupMode" VALUE="0">
<PARAM NAME="ScreenSnap" VALUE="0">
<PARAM NAME="SnapBuffer" VALUE="10">
<PARAM NAME="DockSite" VALUE="0">
<PARAM NAME="DoubleBuffered" VALUE="0">
<PARAM NAME="ParentDoubleBuffered" VALUE="0">
<PARAM NAME="UseDockManager" VALUE="0">
<PARAM NAME="Enabled" VALUE="-1">
<PARAM NAME="AlignWithMargins" VALUE="0">
<PARAM NAME="ParentCustomHint" VALUE="-1">
<PARAM NAME="BorderWidth" VALUE="0">
<PARAM NAME="Color" VALUE="#FFFFFF">
<PARAM NAME="ID" VALUE="12642816840914674888886148967E10FAA617B0F8292A1C5A5C5AC97BB6">
<PARAM NAME="Server" VALUE="https://sd.itsm.n**************n.com/vsm/ServiceManager.aspx?">
<PARAM NAME="HTML" VALUE='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">&#13;&#10;<HTML><HEAD>&#13;&#10;<META content="text/html; charset=windows-1252" http-equiv=Content-Type>&#13;&#10;<META name=GENERATOR content="MSHTML 11.00.9600.18500">&#13;&#10;<STYLE>BODY {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TABLE {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TH {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TD {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;P {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;UL {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;LI {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;OL {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;INPUT {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;SELECT {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TEXTAREA {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;BODY {&#13;&#10;&#9;BORDER-TOP-STYLE: none; BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none&#13;&#10;}&#13;&#10;P {&#13;&#10;&#9;MARGIN: 0.5em 0px&#13;&#10;}&#13;&#10;</STYLE>&#13;&#10;</HEAD>&#13;&#10;<BODY>&#13;&#10;<P>search for this</P></BODY></HTML>&#13;&#10;'>
<PARAM NAME="ReadOnly" VALUE="0">
<PARAM NAME="ImageMode" VALUE="1">
<PARAM NAME="EditorMode" VALUE="0">
<PARAM NAME="HTMLSurroundingField" VALUE='<FONT style="BACKGROUND-COLOR: #ff8080" contentEditable=false DEL_ME=1></FONT>'>
<PARAM NAME="BodyHTML" VALUE="<P>search for this</P>">
<PARAM NAME="AnchorReplaceString" VALUE="">
<PARAM NAME="HTMLField" VALUE="EXTFLDV_500517_HTML">
<PARAM NAME="PlainTextField" VALUE="EXTFLDV_500517">
<PARAM NAME="BodyOnly" VALUE="-1">
<PARAM NAME="BodyClassName" VALUE="">
<PARAM NAME="ItemFormat" VALUE="2">
<PARAM NAME="ItemFormatField" VALUE="FORMAT">
<PARAM NAME="SystemFormatField" VALUE="SystemTextFormat">
<PARAM NAME="ConvertToSystemFormat" VALUE="-1">
<PARAM NAME="AutoPopulate" VALUE="-1">
<PARAM NAME="AsText" VALUE="search for this">
<PARAM NAME="Format" VALUE="2">
<PARAM NAME="DisplayOptions" VALUE="7">
<PARAM NAME="StyleText" VALUE="BODY, TABLE, TH, TD, P, UL, LI, OL, INPUT, SELECT, TEXTAREA {&#13;&#10;font-size:11px;&#13;&#10;font-family: Tahoma, Microsoft Sans Serif, Arial, sans-Serif;&#13;&#10;color:#000000;&#13;&#10;}&#13;&#10;BODY {border-style:none;}&#13;&#10;P {margin: 0.5em 0}">
<PARAM NAME="Freeze" VALUE="0">
<PARAM NAME="PrintMode" VALUE="1">
<PARAM NAME="PreserveStyles" VALUE="0">
</OBJECT></DIV></DIV></TD></TR></TBODY></TABLE></DIV></DIV>

I know this is a freaking mess but I am pretty sure I need to edit the param name="HTML" section.

I don't know how to get autoit to reference this specific section so I can read only that and edit only that.

When I use ie.au3 functions to read the innerhtml, it grabs this:

<PARAM NAME="Visible" VALUE="-1"><PARAM NAME="AutoScroll" VALUE="0"><PARAM NAME="AutoSize" VALUE="0"><PARAM NAME="AxBorderStyle" VALUE="1"><PARAM NAME="Caption" VALUE=""><PARAM NAME="Font" VALUE="Tahoma"><PARAM NAME="KeyPreview" VALUE="0"><PARAM NAME="PixelsPerInch" VALUE="96"><PARAM NAME="PrintScale" VALUE="1"><PARAM NAME="Scaled" VALUE="-1"><PARAM NAME="DropTarget" VALUE="0"><PARAM NAME="HelpFile" VALUE=""><PARAM NAME="PopupMode" VALUE="0"><PARAM NAME="ScreenSnap" VALUE="0"><PARAM NAME="SnapBuffer" VALUE="10"><PARAM NAME="DockSite" VALUE="0"><PARAM NAME="DoubleBuffered" VALUE="0"><PARAM NAME="ParentDoubleBuffered" VALUE="0"><PARAM NAME="UseDockManager" VALUE="0"><PARAM NAME="Enabled" VALUE="-1"><PARAM NAME="AlignWithMargins" VALUE="0"><PARAM NAME="ParentCustomHint" VALUE="-1"><PARAM NAME="BorderWidth" VALUE="0"><PARAM NAME="Color" VALUE="#FFFFFF"><PARAM NAME="ID" VALUE="12642816840914674888886148967E10FAA617B0F8292A1C5A5C5AC97BB6"><PARAM NAME="Server" VALUE="https://sd.itsm.northropgrumman.com/vsm/ServiceManager.aspx?"><PARAM NAME="HTML" VALUE='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">&#13;&#10;<HTML><HEAD>&#13;&#10;<META content="text/html; charset=windows-1252" http-equiv=Content-Type>&#13;&#10;<META name=GENERATOR content="MSHTML 11.00.9600.18500">&#13;&#10;<STYLE>BODY {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TABLE {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TH {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TD {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;P {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;UL {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;LI {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;OL {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;INPUT {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;SELECT {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;TEXTAREA {&#13;&#10;&#9;FONT-SIZE: 11px; FONT-FAMILY: Tahoma, Microsoft Sans Serif, Arial, sans-Serif; COLOR: #000000&#13;&#10;}&#13;&#10;BODY {&#13;&#10;&#9;BORDER-TOP-STYLE: none; BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none&#13;&#10;}&#13;&#10;P {&#13;&#10;&#9;MARGIN: 0.5em 0px&#13;&#10;}&#13;&#10;</STYLE>&#13;&#10;</HEAD>&#13;&#10;<BODY>&#13;&#10;<P>search for this</P></BODY></HTML>&#13;&#10;'><PARAM NAME="ReadOnly" VALUE="0"><PARAM NAME="ImageMode" VALUE="1"><PARAM NAME="EditorMode" VALUE="0"><PARAM NAME="HTMLSurroundingField" VALUE='<FONT style="BACKGROUND-COLOR: #ff8080" contentEditable=false DEL_ME=1></FONT>'><PARAM NAME="BodyHTML" VALUE="<P>search for this</P>"><PARAM NAME="AnchorReplaceString" VALUE=""><PARAM NAME="HTMLField" VALUE="EXTFLDV_500517_HTML"><PARAM NAME="PlainTextField" VALUE="EXTFLDV_500517"><PARAM NAME="BodyOnly" VALUE="-1"><PARAM NAME="BodyClassName" VALUE=""><PARAM NAME="ItemFormat" VALUE="2"><PARAM NAME="ItemFormatField" VALUE="FORMAT"><PARAM NAME="SystemFormatField" VALUE="SystemTextFormat"><PARAM NAME="ConvertToSystemFormat" VALUE="-1"><PARAM NAME="AutoPopulate" VALUE="-1"><PARAM NAME="AsText" VALUE="search for this"><PARAM NAME="Format" VALUE="2"><PARAM NAME="DisplayOptions" VALUE="7"><PARAM NAME="StyleText" VALUE="BODY, TABLE, TH, TD, P, UL, LI, OL, INPUT, SELECT, TEXTAREA {&#13;&#10;font-size:11px;&#13;&#10;font-family: Tahoma, Microsoft Sans Serif, Arial, sans-Serif;&#13;&#10;color:#000000;&#13;&#10;}&#13;&#10;BODY {border-style:none;}&#13;&#10;P {margin: 0.5em 0}"><PARAM NAME="Freeze" VALUE="0"><PARAM NAME="PrintMode" VALUE="1"><PARAM NAME="PreserveStyles" VALUE="0">

When I use the other read html functions it gets the html of the entire body.

Reading innertext and outertext produces nothing.

innerhtml is what gets me closest to zeroing in on exactly what I want to edit. I know that once I can reference and read that exact parameter that I will be able to reference it for writing.

Here is my current code I am using to read from that object if it makes a difference.

#include <IE.au3>
#include <MsgBoxConstants.au3>


$oIE =  _IEAttach("VMware Service Manager", "embedded", 1)
Local $oFrame = _IEFrameGetCollection($oIE,2)

Local $oForm = _IEFormGetObjByName($oFrame, "Form1")
Local $oFormElements = _IEFormElementGetCollection($oForm)
Local $probDesc = _IEFormElementGetObjByName($oForm, "EXTFLDV_500517_HTML_EDITOR")
Local $sHTML = _IEPropertyGet($probDesc, "innerhtml")

MsgBox($MB_SYSTEMMODAL, "VALUE ", $sHTML)
ClipPut($sHTML)

 

Thanks for any and all input. I hope I was thorough enough in my explanation.

Capture.JPG

Link to comment
Share on other sites

Figured it out on my own. I could reference any of the param field values by using $variable.param name

I am going to update this in case anyone else has this issue in the future.

 

#include <IE.au3>
#include <MsgBoxConstants.au3>


$oIE =  _IEAttach("VMware Service Manager", "embedded", 1)
Local $oFrame = _IEFrameGetCollection($oIE,2)

Local $oForm = _IEFormGetObjByName($oFrame, "Form1")
Local $oFormElements = _IEFormElementGetCollection($oForm)
Local $probDesc = _IEFormElementGetObjByName($oForm, "EXTFLDV_500517_HTML_EDITOR")
Local $sHTML = $probDesc.html ;this is the field I needed to reference.

$probDesc.html = "THIS WORKS" ;I was able to write to it successfully with this.

 

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