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