Page 1 of 1 1
Topic Options
#77684 - 2001-04-26 09:03 PM Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I have tried to convert Bryces OLE code for sending HTML to IE to COM in K2k and have a little problem:

code:

; HTML source code
$html=<html>hello</html>


; create IE object (works)
$ie=createobject("internetexplorer.application")


; display form (works)
$ie.visible="true"


; open a blank page (works)
$ie.navigate("about:blank")
while $ie.busy<>0 and @error=0 loop


; Get a handle to the open document. $doc is a object according to vartypename() so I think this works
$doc=$ie.document


; write the data in $html to document. Doesn't work
$doc.write="$html"


I have tried every combination of $ie.document and .write that I can think of. These cause Dr Watson:

$doc.write()="$html"
$doc.write("$html")

I have also tried $ie.document.write to no avail

help?

Here is the original OLE source

code:

$ie = olecreateobject("internetexplorer.application")


$nul = oleputproperty($ie, "visible", "s", "$true")


$nul = olecallfunc($ie, "navigate", "s", "about:blank")
$current = olegetproperty($ie, "busy")
while olegetproperty($ie, "busy") <> "0" and @error = 0 loop


; Get a handle to the open document ...
$doc = val("&" + olegetproperty($ie, "document"))


$nul = olecallfunc($doc, "write", "s", "$html")


cj

Top
#77685 - 2001-04-26 09:18 PM Re: Using COM on IE
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3164
Loc: Houston TX
Shawn is the OLE guru around these parts (he taught me how to do that code)... but I think the general consensus on Kix2001 and OLE/COM, is wait-n-see. Some things aren't fully working yet. :P

Bryce

------------------
kix.isorg.net

Top
#77686 - 2001-04-26 09:48 PM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I got it working, but now another problem. I know it is not fully working yet, but I want to see what I CAN do.

I can write to a text box in IE with

$doc=$ie.document
$element=$doc.GetElementById("textboxID")
$element.Value("set to this")

But I can't read the value back. $element.value errors and $element.value() erases the value. .innerHTML() also erases the value.

Any ideas?

cj

Top
#77687 - 2001-04-26 10:00 PM Re: Using COM on IE
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ceej:

Let's see your working code !

Shawn.

Top
#77688 - 2001-04-26 10:05 PM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
A simple text box. The default value is set by the HTML source.

I would like to read the VALUE, but you will see that the $e.value() writes to it instead. I have tried CheckBoxes too, and the Checked parameter writes. I am looking for the reading command.

code:

break on cls
$html='<html><INPUT id=Status1 value="hello"></html>'


; create HTML file
$=redirectoutput("@curdir\3t.htm", 1) $html ? $=redirectoutput("")


; open IE
$ie=createobject("internetexplorer.application")


; Set properties and display form ...
$ie.addressbar="0"
$ie.menubar="0"
$ie.toolbar="0"
$ie.statusbar="0"
$ie.resizable="0"
$ie.height=440
$ie.width=380
$ie.visible="true"


; open HTML file
$ie.navigate("@curdir\3t.htm") while $ie.busy<>0 and @error=0 loop


; get document handle
$doc=$ie.document
"$$doc is type " vartypename($doc) ?


; get element handle
$e=$doc.GetElementById("status1")
"$$e is type " vartypename($e) ?


"paused..." get$


; display element value
$e.value() ?


cj

Top
#77689 - 2001-05-17 01:29 AM Re: Using COM on IE
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3164
Loc: Houston TX
CJ have you worked on this any more?

------------------
kix.isorg.net

Top
#77690 - 2001-05-17 04:44 PM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
This was the HTML TicTacToe code. With this and a little more hair loss I discovered that you cannot WRITE to anything on a web page in IE with KiX2k COM calls.

But, KiX3.6x WRITES just fine, so HTML TTT is .KIX, not .K2K

Ruud, is this the case?


cj

------------------
cj's scripts page
cj's User Guide - 14 May 2001

chrismat@ozemail.com.au

Top
#77691 - 2001-05-17 05:01 PM Re: Using COM on IE
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3164
Loc: Houston TX
Error using the write command...

I was trying the same thing, and that was why I was asking.

I have tried

$doc.write("$html")
causes an invalid function call

$doc.write = "$html"
will return
@serror = COM automation error: 80004001 [1/1]
@error = 1


One thing i noticed is that i could not get a handle to the $ie.document object unless i did a $ie.navigate first.

code:

$title = "Dropdown_Prompt"
$top = "100"
$left = "200"
$height = "165"
$width = "275"
$false = 0
$true = -1
$html = "test"


$ie = createobject("internetexplorer.application")
if $ie = 0 exit endif

$ie.addressbar = $false
$ie.menubar = $false
$ie.toolbar = $false
$ie.statusbar = $false
$ie.resizable = $false
$ie.top = $top
$ie.left = $left
$ie.height = $height
$ie.width = $width
$ie.visible = $true


debug on
while $ie.busy <>0 and @error = 0 loop

$ie.navigate("http://microsoft.com")
$doc = $ie.document

? @error
? vartype($ie)
? vartype($doc)

$doc.write = $html

? @error
? @serror


Bryce

------------------
kix.isorg.net

Top
#77692 - 2001-05-17 06:20 PM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Yes, I found the same thing. It is due to the 'you can't send info to the COM object' problem. You can all functions, but you can't actually send VALUEs :frustrated: :aaarrrggghhh!:

cj

Top
#77693 - 2001-09-14 11:08 PM Re: Using COM on IE
Anonymous
Unregistered


I'm sure if anyone has posted an update to this, but this should work!!!

$ie=createobject("internetexplorer.application")
$ie.addressbar="0"
$ie.menubar="0"
$ie.toolbar="0"
$ie.statusbar="0"
$ie.resizable="0"
$ie.height=440
$ie.width=380
$ie.visible="true"

$ie.navigate("about:blank") while $ie.busy<>0 and @error=0 loop

$doc=$ie.document
$= $doc.open
$= $doc.write("<title>Logon script for %username%</title>")

$= $doc.write("<h4>Setting environment variables ...</h4>") sleep (3)
$= $doc.write("<h4>Checking for known viruses ...</h4>") sleep (3)
$= $doc.write("<h4>Mapping network drives ...</h4>") sleep (3)
$= $doc.write("<h4>Cataloging local system ...</h4>") sleep (3)
$= $doc.write("<h4>Checking for Internet Explorer updates ...</h4>") sleep (3)
$= $doc.write("<h4>Updating Internet Explorer ...</h4>") sleep (3)
$= $doc.close
$ie.quit
$ie=0

Top
#77694 - 2001-09-14 11:32 PM Re: Using COM on IE
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11557
Loc: CA
Works on KiXtart 2001 RC3 for me.

Did not bring app to the foreground though.

Top
#77695 - 2001-09-15 01:55 AM Re: Using COM on IE
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3164
Loc: Houston TX
all of these com bugs were fixed with RC1 and greater....

I have used COM and IE interface read/write in this UDF here. GUIPassPrompt

Bryce

Top
#77696 - 2001-09-19 10:17 AM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I had forgotten this post :s

I have since solved this problem and even released a KiX2k version of TicTacToe (I can't find it, but it's on this board somewhere)

cj

Top
#77697 - 2001-09-19 10:33 AM Re: Using COM on IE
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Here it is: New, faster TicTacToe game (RC1 only)

cj

Top
#77698 - 2001-09-27 11:14 PM Re: Using COM on IE
Anonymous
Unregistered


Hey Guys,

Re: IE Automation... Check this out. Built for KiXtart 2001 and based on all of the previous posts regarding COM automation and IE. Enjoy!


HTMLInputBox("What is your favorite color?","Color Quiz","Red","Submit Me!","Yellow","Black","I don't know!!!")

;HTML Input Box:
;
; ACTION:
; Displays an Input-box that allows a user to input a string. This box is HTML based and
; uses the Internet Explorer Application object.
;
; SYNTAX:
; HTMLInputBox("HTML Message", OPTIONAL "Window Title", OPTIONAL "Default Value",OPTIONAL "Button Text", OPTIONAL "Text Color", OPTIONAL "Background Color", OPTIONAL "Alt Button Text", OPTIONAL "Alt Button Return Value")
;
; PARAMETERS:
; HTML Message: The message for the Input Box. ex: What is your favorite color? Note: This can accept any HTML code, so go to town! Also Note: the <b> tag is enabled, so if you want to do custom HTML, put </b> as the first tag.
; Window Title: ( OPTIONAL ) The title of the HTML Input Box Window. If blank, defaults to "Question...".
; Default Value: ( OPTIONAL ) The default value for the box which will show when the box appears. If blank, defaults to blank.
; Button Text: ( OPTIONAL ) The text on the main button. If blank, default is "SUBMIT".
; Text Color: ( OPTIONAL ) The color of text on the input box. If blank, this defaults to black. Note: This can be overridden by including additional HTML tags in the HTML Message.
; Background Color: ( OPTIONAL ) The color of the background of the HTML form. Defaults to silver.
; Alt Button Text: ( OPTIONAL ) If this is specified, an alternate button will appear on the form and if clicked, the function will (by default) return "-1". This is useful as a "HELP" button, or for many other purposes.
; Alt Button Return Value: ( OPTIONAL ) If the Alt button is needed, and -1 is a potential legitimate return value for the main submit button, you can specify an alternate return value for the alternate button.
;
; REMARKS:
; This has been tested by the author on Win 98 and Win 2k machines. It should require at least IE 4.0 to function, however it does not check the IE version before executing.
;
; RETURNS:
; The string in the text box, or another value if the "Alternate button" is pressed. The alternate value defaults to -1, but can be changed by specifying the "Alt Button Return Value".
;
; EXAMPLE:
; HTMLInputBox("What is your favorite color?","Color Quiz","Red","Submit Me!","Black","Yellow","I don't know!!!")
;


FUNCTION HTMLInputBox($L_Prompt, OPTIONAL $L_Title, OPTIONAL $L_DefaultValue, OPTIONAL $L_ButtonText, OPTIONAL $L_TextColor, OPTIONAL $L_BGColor, OPTIONAL $L_AltButtonText, OPTIONAL $L_AltButtonReturnValue)

IF $L_Title = ""
$L_Title = "Question..."
ENDIF

IF $L_ButtonText = ""
$L_ButtonText = "Submit"
ENDIF

IF $L_AltButtonReturnValue = ""
$L_AltButtonReturnValue = -1
ENDIF

SELECT
CASE $L_TextColor = "Black"
$L_TextColor = "000000"
CASE $L_TextColor = "Silver"
$L_TextColor = "C0C0C0"
CASE $L_TextColor = "Gray"
$L_TextColor = "808080"
CASE $L_TextColor = "White"
$L_TextColor = "FFFFFF"
CASE $L_TextColor = "Maroon"
$L_TextColor = "800000"
CASE $L_TextColor = "Red"
$L_TextColor = "FF0000"
CASE $L_TextColor = "Purple"
$L_TextColor = "800080"
CASE $L_TextColor = "Fuchsia"
$L_TextColor = "FF00FF"
CASE $L_TextColor = "Green"
$L_TextColor = "008000"
CASE $L_TextColor = "Lime"
$L_TextColor = "00FF00"
CASE $L_TextColor = "Olive"
$L_TextColor = "808000"
CASE $L_TextColor = "Yellow"
$L_TextColor = "FFFF00"
CASE $L_TextColor = "Navy"
$L_TextColor = "000080"
CASE $L_TextColor = "Blue"
$L_TextColor = "0000FF"
CASE $L_TextColor = "Teal"
$L_TextColor = "008080"
CASE $L_TextColor = "Aqua"
$L_TextColor = "00FFFF"
CASE $L_TextColor = ""
$L_TextColor = "000000"
ENDSELECT

SELECT
CASE $L_BGColor = "Black"
$L_BGColor = "000000"
CASE $L_BGColor = "Silver"
$L_BGColor = "C0C0C0"
CASE $L_BGColor = "Gray"
$L_BGColor = "808080"
CASE $L_BGColor = "White"
$L_BGColor = "FFFFFF"
CASE $L_BGColor = "Maroon"
$L_BGColor = "800000"
CASE $L_BGColor = "Red"
$L_BGColor = "FF0000"
CASE $L_BGColor = "Purple"
$L_BGColor = "800080"
CASE $L_BGColor = "Fuchsia"
$L_BGColor = "FF00FF"
CASE $L_BGColor = "Green"
$L_BGColor = "008000"
CASE $L_BGColor = "Lime"
$L_BGColor = "00FF00"
CASE $L_BGColor = "Olive"
$L_BGColor = "808000"
CASE $L_BGColor = "Yellow"
$L_BGColor = "FFFF00"
CASE $L_BGColor = "Navy"
$L_BGColor = "000080"
CASE $L_BGColor = "Blue"
$L_BGColor = "0000FF"
CASE $L_BGColor = "Teal"
$L_BGColor = "008080"
CASE $L_BGColor = "Aqua"
$L_BGColor = "00FFFF"
CASE $L_BGColor = ""
$L_BGColor = "C0C0C0"
ENDSELECT


$HTML = '<HTML>' +
'<BODY TEXT=' + $L_TextColor + ' BGCOLOR=' +
$L_BGColor + '>' +
'<TITLE>' + $L_Title + '</TITLE><B>' +
$L_Prompt + '</B>' +
'<form name=CompTrends>' +
'<BR>' +
'<input id=Answer name=Answer class=tbox' +
' value="' + $L_DefaultValue + '" Tabindex="1"> ' +
'<input id=Submitted name=Submitted type=hidden value=0>' +
'<input id=Submit name=Submit type=button value=" ' +
$L_ButtonText + ' "' +
' onclick="CompTrends.Submitted.value=1" Tabindex="2">'

IF $L_AltButtonText <> ""
$HTML = $HTML + '<input id=AltButton name=AltButton type=button value=" ' +
$L_AltButtonText + ' "' +
' onclick="CompTrends.Submitted.value=2" Tabindex="3">'
ENDIF

$HTML = $HTML + '</FORM>' +
'</BODY></HTML>'

$appIE = CREATEOBJECT("InternetExplorer.Application")

;Set IE Object Properties
$appIE.top = 30
$appIE.left = 30
$appIE.height = 350
$appIE.width = 500
$appIE.addressbar = 0
$appIE.menubar = 0
$appIE.toolbar = 0
$appIE.statusbar = 0
$appIE.resizeable = 0
$appIE.navigate("about:blank")
WHILE $appIE.busy <> 0 AND @ERROR = 0
LOOP


;Write the HTML code to the document
$appIE.document.write($HTML)

WHILE $appIE.busy <> 0 AND @ERROR = 0
LOOP

;Make IE visible and set focus
$appIE.visible = 1
$= SETFOCUS("about:blank - Microsoft Internet Explorer")
$appIE.document.GetElementById("Answer").focus

DIM $L_LastBoxValue,$L_LastBoxValueCache
WHILE $appIE.document.GetElementById("Submitted").value = 0
IF $appIE.document.GetElementById("Submit").value = " " + $L_ButtonText + " "
IF $appIE.document.GetElementById("Answer").value <> ""
$L_LastBoxValue = $appIE.document.GetElementById("Answer").value
IF $L_LastBoxValue <> ""
$L_LastBoxValueCache = $L_LastBoxValue
ENDIF
ENDIF
ENDIF
LOOP

IF $appIE.document.GetElementById("Submitted").value = 2
$HTMLInputBox = $L_AltButtonReturnValue
ELSE
$HTMLInputBox = $L_LastBoxValueCache
ENDIF

$appIE.QUIT
$appIE = ""
ENDFUNCTION

Top
#77699 - 2001-09-28 09:01 PM Re: Using COM on IE
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hey Steve ...

VERY CLEVER !!!

Works like a champ and is a heck of alot prettier / more sohisicated than that built-in VBScript/JScript inputbox ...

-Shawn

Top
#77700 - 2001-10-01 06:21 PM Re: Using COM on IE
Anonymous
Unregistered


Thanks. I thought that this needed to be written since there's no inputbox() in KiX by default. Ruud was pulling his hairs out for a while since the IE object does some funny things and I kept bugging him when something didn't work right. We must have run into and fixed about 4 separate GPF's in the course of developing this UDF. But I think it was worth it. ;-)

-Steve O

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 177 anonymous users online.
Newest Members
dboozcruise, 2786707460, Marc57, EricMyers, siddharthinfosy
17519 Registered Users

Generated in 0.069 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.