#67566 - 2002-06-26 04:36 PM
ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Rad & Shawn, I need to run with the "big dogs" again. Here is what I am trying to do...
1) Build a "filtered machine list" array from a NT4 domain (not 2000 - Without using NetDom!)
2) Use Rad's Functions to allow a selection of the array.
3) Get the machine selection returned to Kix
Then I can use the name to do whatever... What have I done wrong here???
code:
;$=setconsole("minimize") ;Build array of desired machines break on $ElementArray="" $cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" for each $machine in $cont $obj = $cont.getobject("computer",$machine) If Substr("$obj",2,3)="ACS" ;filter for machine names $ElementArray=$ElementArary + ", "+$obj Endif next get $ ;****************** For Each $Element In $ElementArray ;Test to see array ? $Element Next
$Window = IECreateWindow("This Damn Thing",300,300,640,480)
IEWrite($Window,"hello","Arial","4","#00ff00") IEWrite($Window,"hello1",,"2","#ff0000") IEWrite($Window,"hello2","Courier","5","#0000ff") IEWrite($Window,"hello3") IEComboBox($Window,"This Damn Thing","Test IT","$ElementArray") ;pass array $b1=IEAddButton($Window,"Button1",10,0,50,25) $b2=IEAddButton($Window,"Button2",70,0,50,25) $b3=IEAddButton($Window,"Button3",130,0,50,25) ?"pause..." get$k
$window.quit $window = 0 exit 1 ;&&&&&&&&&&&&&&&&&&&&&&&
;***********************************************************************************************
Function IEComboBox($Window,$title,$text,$ElementArray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT></BODY></HTML> ' $window.document.write('$html') WHILE $window.busy <> 0 AND @ERROR = 0 LOOP
$combobox=IE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0]
EndFunction
;*********************************************************************************************** Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop $ie.document.body.scroll = no if $html $ie.document.write('$html') else $ie.document.write('<title>$title</title>') endif $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
Function IEWrite($Window,$text, optional $font, optional $size, optional $color, optional $Clear) if not $font $font='Verdana, Helvetica, sans-serif' endif if not $size $size='3' endif if not $color $color='#000000' endif if not $bgcolor $bgcolor='#ffffff' endif $HTML = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($HTML) WHILE $window.busy <> 0 AND @ERROR = 0 LOOP EndFunction
Function IEAddButton($Window,$Caption,$Left,$Top,$Width,$Height) dim $Button $Button = $Window.Document.CreateElement("input") $Button.Type = "Button" $Button.Value = $Caption $Button.Style.Position = "Absolute" $Button.Style.PixelTop = $Top $Button.Style.PixelLeft = $Left $Button.Style.PixelWidth = $Width $Button.Style.PixelHeight = $Height $Button = $Window.Document.Body.AppendChild($Button) $IEAddButton = $Button EndFunction
Function IESetBackColor($Window,$Color) $Window.Document.Body.BGColor = $Color EndFunction
Function IEInputBox($title, Optional $prompt, optional $Ok, optional $Cancel) Dim $click, $html, $Window, $status, $click, $button, $box
If not $prompt $prompt = "Please enter your password." endif If not $ok $ok = "OK" endif If not $Cancel $cancel = "Cancel" endif
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$Window = IECreateWindow($title,100,100,300,130,$html) while $window.busy and $window.readystate <> 4 and @error = 0 loop $window.document.GetElementById("input").focus $status = $window.document.GetElementById("status") $click = $window.document.GetElementById("input") $button= 0 $box=0 while @error = 0 and $button = 0 $button=$status.value $box=$click.value select case $button = "1" $IEInputBox = $box case $button = "2" $IEInputBox = "Cancel" endselect loop $window.quit $window="" EndFunction
[ 27 June 2002, 22:32: Message edited by: Dana Eddy ]
|
|
Top
|
|
|
|
#67567 - 2002-06-26 05:22 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Kixstrip shows us:
; -------> Warning KIXSTRIP: 43 line incomplete "single quotation". ; -------> Warning KIXSTRIP: 43 line incompleted. ; -------> Warning KIXSTRIP: 45 line incomplete "single quotation". ; -------> Warning KIXSTRIP: 45 line incompleted.
HTH,
Kent
|
|
Top
|
|
|
|
#67568 - 2002-06-26 05:29 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
This maybe also due to the fact that you are trying to show the code without having a very long line..
Kent
|
|
Top
|
|
|
|
#67569 - 2002-06-26 05:50 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Kent, Line 43 single quote ends at line 45 $html = ' bla, bla, bla'
The problem is still at large... Thanks,
|
|
Top
|
|
|
|
#67570 - 2002-06-26 05:52 PM
Re: ComboBox Function is Working!!!
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Hi Dana,
I see what your doing here - but the problem, me thinks, is that one can't create a dynamic array using a $variable, the way to make this work is to use the Execute() function. Here's an example using the top part of your script:
break on
; Set initially to string
$ElementArray=""
; Enumerate hostnames in the domain
$cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" for each $machine in $cont $obj = $machine.name $ElementArray=$ElementArray + ", "+$obj ; append to string, comma-delimed next
; Morph the comma-delimed string into an array ...
$=execute('$$ElementArray = split($$ElementArray,",")')
;******************
; Enumerate the array ...
For Each $Element In $ElementArray ;Test to see array ? "Element=" $Element Next
The other way is to create (DIM) a real array, then populate and dynamically REDIM PRESERVE along the way. Hope this helps.
-Shawn
|
|
Top
|
|
|
|
#67572 - 2002-06-26 06:02 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn, Glad to see you jump on this one, Thanx!!! OK, that solves problem 1... I owe you a Duh for that one...What was I thinking???
For problem 2 & 3 build a quick array lets say: $ElementArray = "machine1, machine2, machine3"
How do I make the HTML work? Get the list into ie and get the selection back???
I R one lost pup
|
|
Top
|
|
|
|
#67573 - 2002-06-26 06:12 PM
Re: ComboBox Function is Working!!!
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
You got a typo in your ComboBox function:
$combobox=IE.document.GetElementById("combobox")
forgot the $ on IE
Plus, might want to take the quotes off $ElementArray when passed to the cComboBox function.
This is looking great ! [ 26 June 2002, 18:12: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#67574 - 2002-06-26 06:30 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn, Here is what I have done; It only goes to 1 line in the combobox. Whuzz Up? code:
:starthere $ElementArray = "machine1", "machine2", "machine3" ; Enumerate the array ... For Each $Element In $ElementArray ;Test to see array ? "Element=" $Element Next ;&&&&&&&&&&&&&&&&&&&&&&& ;***********************************************************************************************
Function IEComboBox($Window,$title,$text,$ElementArray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT></BODY></HTML> ' $window.document.write('$html') WHILE $window.busy <> 0 AND @ERROR = 0 LOOP
$combobox=$IE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0]
EndFunction
|
|
Top
|
|
|
|
#67575 - 2002-06-26 06:33 PM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
BTW, I don't think I ever got the combobox thing to work completely... I just budged it together...
If you make and changed to the functions to get them working let me know...
|
|
Top
|
|
|
|
#67576 - 2002-06-26 06:37 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I need some help here.
Trying to play with the "Big Dogs" too!
Also, when I run this I get: quote:
Script error : unknown command ! $combobox.value=$elementarray[0]
I took your code and it enumerates the computers on the domain, but does not populate in IE..
code:
BREAK ON
; Set initially to string
$elementarray=""
; Enumerate hostnames in the domain
$cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" FOR EACH $machine IN $cont $obj = $machine.name $elementarray=$elementarray + ", "+$obj ; append to string, comma-delimed NEXT
; Morph the comma-delimed string into an array ...
$elementarray=execute('$$ElementArray = split($$ElementArray,",")')
; -- Shawn's Suggestion ;$ElementArray = split($$ElementArray,",")
;******************
; Enumerate the array ...
FOR EACH $element IN $elementarray ;Test to see array ? "Element=" $element NEXT
$window = IECreateWindow("This Damn Thing",300,300,640,480)
IEWrite($window,"hello","Arial","4","#00ff00") IEWrite($window,"hello1",,"2","#ff0000") IEWrite($window,"hello2","Courier","5","#0000ff") IEWrite($window,"hello3") IEComboBox($window,"This Damn Thing","Test IT","$ElementArray") ;pass array $b1=IEAddButton($window,"Button1",10,0,50,25) $b2=IEAddButton($window,"Button2",70,0,50,25) $b3=IEAddButton($window,"Button3",130,0,50,25) ?"pause..." GET$k
$window.quit $window = 0 EXIT 1 ;&&&&&&&&&&&&&&&&&&&&&&&
;***********************************************************************************************
FUNCTION IEComboBox($window,$title,$text,$elementarray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </object></body></html> ' $window.document.write('$html') WHILE $window.busy <> 0 AND @error = 0 LOOP
$combobox=$ie.document.getelementbyid("combobox") FOR EACH $element IN $elementarray $=$combobox.additem("$Element") NEXT $combobox.value=$elementarray[0]
ENDFUNCTION
;*********************************************************************************************** FUNCTION IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") WHILE $ie.busy AND $ie.readystate <> 4 AND @error = 0 LOOP $ie.document.body.scroll = no IF $html $ie.document.write('$html') ELSE $ie.document.write('<title>$title</title>') ENDIF $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $iecreatewindow = $ie $ie.visible = 1 WHILE setfocus("$title") <> 0 LOOP ENDFUNCTION
FUNCTION IEWrite($window,$text, optional $font, optional $size, optional $color, optional $clear) IF NOT $font $font='Verdana, Helvetica, sans-serif' ENDIF IF NOT $size $size='3' ENDIF IF NOT $color $color='#000000' ENDIF IF NOT $bgcolor $bgcolor='#ffffff' ENDIF $html = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($html) WHILE $window.busy <> 0 AND @error = 0 LOOP ENDFUNCTION
FUNCTION IEAddButton($window,$caption,$left,$top,$width,$height) DIM $button $button = $window.document.createelement("input") $button.type = "Button" $button.value = $caption $button.style.position = "Absolute" $button.style.pixeltop = $top $button.style.pixelleft = $left $button.style.pixelwidth = $width $button.style.pixelheight = $height $button = $window.document.body.appendchild($button) $ieaddbutton = $button ENDFUNCTION
FUNCTION IESetBackColor($window,$color) $window.document.body.bgcolor = $color ENDFUNCTION
FUNCTION IEInputBox($title, Optional $prompt, optional $ok, optional $cancel) DIM $click, $html, $window, $status, $click, $button, $box
IF NOT $prompt $prompt = "Please enter your password." ENDIF IF NOT $ok $ok = "OK" ENDIF IF NOT $cancel $cancel = "Cancel" ENDIF
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$window = IECreateWindow($title,100,100,300,130,$html) WHILE $window.busy AND $window.readystate <> 4 AND @error = 0 LOOP $window.document.getelementbyid("input").focus $status = $window.document.getelementbyid("status") $click = $window.document.getelementbyid("input") $button= 0 $box=0 WHILE @error = 0 AND $button = 0 $button=$status.value $box=$click.value SELECT CASE $button = "1" $ieinputbox = $box CASE $button = "2" $ieinputbox = "Cancel" ENDSELECT LOOP $window.quit $window="" ENDFUNCTION
Thanks!
Kent
|
|
Top
|
|
|
|
#67577 - 2002-06-26 06:54 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Kent, I received the same error when the parameter passed ($ElementArray) is not an array. R U sure that the array is an array? I am at home now and don't have a NT4 Domain to test it on right now.
|
|
Top
|
|
|
|
#67578 - 2002-06-26 07:00 PM
Re: ComboBox Function is Working!!!
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Seems to work pretty good for me. Maybe I changed (fixed) something by accident. Here's the code, using Kixtart 4.10 RC1 at the moment.
code:
break on
$ElementArray="machine1","machine2","machine3"
$Window = IECreateWindow("This Damn Thing",300,300,640,480)
IEWrite($Window,"hello","Arial","4","#00ff00") IEWrite($Window,"hello1",,"2","#ff0000") IEWrite($Window,"hello2","Courier","5","#0000ff") IEWrite($Window,"hello3")
IEComboBox($Window,"This Damn Thing","Test IT",$ElementArray) ;pass array
$b1=IEAddButton($Window,"Button1",10,0,50,25) $b2=IEAddButton($Window,"Button2",70,0,50,25) $b3=IEAddButton($Window,"Button3",130,0,50,25)
?"pause..." get$k
$window.quit $window = 0 exit 1 ;&&&&&&&&&&&&&&&&&&&&&&&
;***********************************************************************************************
Function IEComboBox($Window,$title,$text,$ElementArray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT></BODY></HTML> ' $window.document.write('$html')
WHILE $window.busy <> 0 AND @ERROR = 0 LOOP
$combobox = $IE.document.GetElementById("combobox")
for each $element in $ElementArray $=$combobox.additem("$Element") next
$combobox.value=$ElementArray[0]
EndFunction
;*********************************************************************************************** Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop $ie.document.body.scroll = no if $html $ie.document.write('$html') else $ie.document.write('<title>$title</title>') endif $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
Function IEWrite($Window,$text, optional $font, optional $size, optional $color, optional $Clear) if not $font $font='Verdana, Helvetica, sans-serif' endif if not $size $size='3' endif if not $color $color='#000000' endif if not $bgcolor $bgcolor='#ffffff' endif $HTML = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($HTML) WHILE $window.busy <> 0 AND @ERROR = 0 LOOP EndFunction
Function IEAddButton($Window,$Caption,$Left,$Top,$Width,$Height) dim $Button $Button = $Window.Document.CreateElement("input") $Button.Type = "Button" $Button.Value = $Caption $Button.Style.Position = "Absolute" $Button.Style.PixelTop = $Top $Button.Style.PixelLeft = $Left $Button.Style.PixelWidth = $Width $Button.Style.PixelHeight = $Height $Button = $Window.Document.Body.AppendChild($Button) $IEAddButton = $Button EndFunction
Function IESetBackColor($Window,$Color) $Window.Document.Body.BGColor = $Color EndFunction
Function IEInputBox($title, Optional $prompt, optional $Ok, optional $Cancel) Dim $click, $html, $Window, $status, $click, $button, $box
If not $prompt $prompt = "Please enter your password." endif If not $ok $ok = "OK" endif If not $Cancel $cancel = "Cancel" endif
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$Window = IECreateWindow($title,100,100,300,130,$html) while $window.busy and $window.readystate <> 4 and @error = 0 loop $window.document.GetElementById("input").focus $status = $window.document.GetElementById("status") $click = $window.document.GetElementById("input") $button= 0 $box=0 while @error = 0 and $button = 0 $button=$status.value $box=$click.value select case $button = "1" $IEInputBox = $box case $button = "2" $IEInputBox = "Cancel" endselect loop $window.quit $window="" EndFunction
|
|
Top
|
|
|
|
#67580 - 2002-06-26 07:28 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn, OK try this code,,, There are no tags on the createbutton function. So, they have no purpose. We need to update the function.. What is desired is to press select and see: "you selected: .." at the cmd line. Pressing cancel will end ie. Do you have ideas?
code:
break on
$ElementArray="machine1","machine2","machine3"
$Window = IECreateWindow("A Simple ComboBox",300,300,640,480) IEWrite($Window,"Select from the list below...","Courier","5","#0000ff") IEComboBox($Window,"A Simple ComboBox","Your Selection",$ElementArray) ;pass array $b1=IEAddButton($Window,"Select",220,80,75,30) $b2=IEAddButton($Window,"Cancel",310,80,75,30) ?"pause..." get$k
$window.quit $window = 0 exit 1 ;&&&&&&&&&&&&&&&&&&&&&&&
;***********************************************************************************************
Function IEComboBox($Window,$title,$text,$ElementArray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=26 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT></BODY></HTML> ' $window.document.write('$html') WHILE $window.busy <> 0 AND @ERROR = 0 LOOP $combobox = $IE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0] EndFunction
;*********************************************************************************************** Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop $ie.document.body.scroll = no if $html $ie.document.write('$html') else $ie.document.write('<title>$title</title>') endif $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
Function IEWrite($Window,$text, optional $font, optional $size, optional $color, optional $Clear) if not $font $font='Verdana, Helvetica, sans-serif' endif if not $size $size='3' endif if not $color $color='#000000' endif if not $bgcolor $bgcolor='#ffffff' endif $HTML = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($HTML) WHILE $window.busy <> 0 AND @ERROR = 0 LOOP EndFunction
Function IEAddButton($Window,$Caption,$Left,$Top,$Width,$Height) dim $Button $Button = $Window.Document.CreateElement("input") $Button.Type = "Button" $Button.Value = $Caption $Button.Style.Position = "Absolute" $Button.Style.PixelTop = $Top $Button.Style.PixelLeft = $Left $Button.Style.PixelWidth = $Width $Button.Style.PixelHeight = $Height $Button = $Window.Document.Body.AppendChild($Button) $IEAddButton = $Button EndFunction
Function IESetBackColor($Window,$Color) $Window.Document.Body.BGColor = $Color EndFunction
Function IEInputBox($title, Optional $prompt, optional $Ok, optional $Cancel) Dim $click, $html, $Window, $status, $click, $button, $box
If not $prompt $prompt = "Please enter your password." endif If not $ok $ok = "OK" endif If not $Cancel $cancel = "Cancel" endif
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$Window = IECreateWindow($title,100,100,300,130,$html) while $window.busy and $window.readystate <> 4 and @error = 0 loop $window.document.GetElementById("input").focus $status = $window.document.GetElementById("status") $click = $window.document.GetElementById("input") $button= 0 $box=0 while @error = 0 and $button = 0 $button=$status.value $box=$click.value select case $button = "1" $IEInputBox = $box case $button = "2" $IEInputBox = "Cancel" endselect loop $window.quit $window="" EndFunction
|
|
Top
|
|
|
|
#67581 - 2002-06-26 07:53 PM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
i've made a few mods to the combobox function and the main script...
see if it works better (it still doesn't work though...)
code:
break on $ElementArray="machine1","machine2","machine3" $Window = IECreateWindow("A Simple ComboBox",300,300,640,480) IEWrite($Window,"Select from the list below...","Courier","5","#0000ff") $box=IEComboBox("A Simple ComboBox","Your Selection",$ElementArray) ;pass array $b1=IEAddButton($box,"Select",220,80,75,30) $b2=IEAddButton($box,"Cancel",310,80,75,30) ?"pause..." get$k $window.quit $window = 0 exit 1
code:
Function IEComboBox($Title,$text,$ElementArray, optional $cancel)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><body scroll=no><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT></BODY></HTML> ' $hsize=250 $vsize=150
$Window = IECreateWindow($title,200,200,$hsize,$vsize,$html) while $window.busy and $window.readystate <> 4 and @error = 0 loop
$combobox=$IE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0] $IEComboBox=$combobox EndFunction
|
|
Top
|
|
|
|
#67583 - 2002-06-26 08:21 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Woohoo! Got this to pull names from the domain and populate IE!!!
code:
BREAK ON
; Set initially to string
$elementarray=""
; -- Build Internet Explorer Window $window = IECreateWindow("This Damn Thing",300,300,640,480)
IEWrite($window,"hello","Arial","4","#00ff00") IEWrite($window,"hello1",,"2","#ff0000") IEWrite($window,"hello2","Courier","5","#0000ff") IEWrite($window,"hello3")
; Enumerate hostnames in the domain
$cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" FOR EACH $machine IN $cont $obj = $machine.name $elementarray=$elementarray + ", "+$obj ; append to string, comma-delimed NEXT
; Morph the comma-delimed string into an array ...
$=execute('$$ElementArray = split($$ElementArray,",")')
;******************
; Enumerate the array ...
FOR EACH $element IN $elementarray ;Test to see array ? "Element=" $element NEXT
IEComboBox($window,"This Damn Thing","Test IT",$element) ;pass array $b1=IEAddButton($window,"Button1",10,0,50,25) $b2=IEAddButton($window,"Button2",70,0,50,25) $b3=IEAddButton($window,"Button3",130,0,50,25)
?"pause..." GET$k
$window.quit $window = 0 EXIT 1
;****************** ; -- Functions used ;****************** FUNCTION IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") WHILE $ie.busy AND $ie.readystate <> 4 AND @error = 0 LOOP $ie.document.body.scroll = no IF $html $ie.document.write('$html') ELSE $ie.document.write('<title>$title</title>') ENDIF $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $iecreatewindow = $ie $ie.visible = 1 WHILE setfocus("$title") <> 0 LOOP ENDFUNCTION FUNCTION IEWrite($window,$text, optional $font, optional $size, optional $color, optional $clear) IF NOT $font $font='Verdana, Helvetica, sans-serif' ENDIF IF NOT $size $size='3' ENDIF IF NOT $color $color='#000000' ENDIF IF NOT $bgcolor $bgcolor='#ffffff' ENDIF $html = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($html) WHILE $window.busy <> 0 AND @error = 0 LOOP ENDFUNCTION ;****************** FUNCTION IEComboBox($window,$title,$text,$element)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </object></body></html> ' $window.document.write('$html')
WHILE $window.busy <> 0 AND @error = 0 LOOP
$combobox = $ie.document.getelementbyid("combobox")
FOR EACH $element IN $elementarray $=$combobox.additem("$Element") NEXT
$combobox.value=$elementarray[0]
ENDFUNCTION ;****************** FUNCTION IEAddButton($window,$caption,$left,$top,$width,$height) DIM $button $button = $window.document.createelement("input") $button.type = "Button" $button.value = $caption $button.style.position = "Absolute" $button.style.pixeltop = $top $button.style.pixelleft = $left $button.style.pixelwidth = $width $button.style.pixelheight = $height $button = $window.document.body.appendchild($button) $ieaddbutton = $button ENDFUNCTION ;****************** FUNCTION IESetBackColor($window,$color) $window.document.body.bgcolor = $color ENDFUNCTION ;****************** FUNCTION IEInputBox($title, Optional $prompt, optional $ok, optional $cancel) DIM $click, $html, $window, $status, $click, $button, $box
IF NOT $prompt $prompt = "Please enter your password." ENDIF IF NOT $ok $ok = "OK" ENDIF IF NOT $cancel $cancel = "Cancel" ENDIF
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$window = IECreateWindow($title,100,100,300,130,$html) WHILE $window.busy AND $window.readystate <> 4 AND @error = 0 LOOP $window.document.getelementbyid("input").focus $status = $window.document.getelementbyid("status") $click = $window.document.getelementbyid("input") $button= 0 $box=0 WHILE @error = 0 AND $button = 0 $button=$status.value $box=$click.value SELECT CASE $button = "1" $ieinputbox = $box CASE $button = "2" $ieinputbox = "Cancel" ENDSELECT LOOP $window.quit $window="" ENDFUNCTION
Cool Stuff!
Kent
|
|
Top
|
|
|
|
#67584 - 2002-06-26 08:31 PM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
the isarray() function would be useful here in validating values in these functions.
Of course making the functions work is probably more important than keeping it working right now...
|
|
Top
|
|
|
|
#67585 - 2002-06-27 01:20 AM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
It just keeps getting better...
Added in a line for proper formatting of HTML -
code:
$html='<html><head><title>$title</title></head><body>'
Very slick results.
I showed this to one of my colleagues and he thought it was pretty cool too...
code:
BREAK ON
; Set initially to string
$elementarray=""
; -- Build Internet Explorer Window $window = IECreateWindow("@Domain - Logon Script",300,300,640,480)
$hour=val(substr(@time,1,2))
SELECT CASE $hour<12 $tod = 'Good Morning' CASE $hour<18 $tod = 'Good Afternoon' CASE 1 $tod = 'Good Evening' ENDSELECT
IEWrite($window,"hello","Arial","4","#00ff00") IEWrite($window,"$tod") IEWrite($window,"@userid",,"2","#ff0000") IEWrite($window,"@fullname","Courier","5","#0000ff") IEWrite($window,"Welcome to the @Domain Domain")
; Enumerate hostnames in the domain
$cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" FOR EACH $machine IN $cont $obj = $machine.name $elementarray=$elementarray + ", "+$obj ; append to string, comma-delimed NEXT
; Morph the comma-delimed string into an array ... $elementarray = split($elementarray,",") ;; $rc=execute('$$ElementArray = split($$ElementArray,",")')
;******************
; Enumerate the array ...
; FOR EACH $element IN $elementarray ;Test to see array ; ? "Element=" $element ; NEXT
IEComboBox($window,"Domain List","Test IT",$element) ;pass array $b1=IEAddButton($window,"Button1",10,0,50,25) $b2=IEAddButton($window,"Button2",70,0,50,25) $b3=IEAddButton($window,"Button3",130,0,50,25)
?"pause..." GET$k
$window.quit $window = 0 EXIT 1
;****************** ; -- Functions used ;****************** FUNCTION IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") WHILE $ie.busy AND $ie.readystate <> 4 AND @error = 0 LOOP $ie.document.body.scroll = no ; -- Added in this line, we want properly formatted HTML: Kent Dyer 26 June 2002 $html='<html><head><title>$title</title></head><body>' IF $html $ie.document.write('$html') ELSE $ie.document.write('<title>$title</title>') ENDIF $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $iecreatewindow = $ie $ie.visible = 1 WHILE setfocus("$title") <> 0 LOOP ENDFUNCTION FUNCTION IEWrite($window,$text, optional $font, optional $size, optional $color, optional $clear) IF NOT $font $font='Verdana, Helvetica, sans-serif' ENDIF IF NOT $size $size='3' ENDIF IF NOT $color $color='#000000' ENDIF IF NOT $bgcolor $bgcolor='#ffffff' ENDIF $html = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($html) WHILE $window.busy <> 0 AND @error = 0 LOOP ENDFUNCTION ;****************** FUNCTION IEComboBox($window,$title,$text,$element)
$html='<BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </object></body></html> ' $window.document.write('$html')
WHILE $window.busy <> 0 AND @error = 0 LOOP
$combobox = $ie.document.getelementbyid("combobox")
FOR EACH $element IN $elementarray $RC=$combobox.additem("$Element") NEXT
$combobox.value=$elementarray[0]
ENDFUNCTION ;****************** FUNCTION IEAddButton($window,$caption,$left,$top,$width,$height) DIM $button $button = $window.document.createelement("input") $button.type = "Button" $button.value = $caption $button.style.position = "Absolute" $button.style.pixeltop = $top $button.style.pixelleft = $left $button.style.pixelwidth = $width $button.style.pixelheight = $height $button = $window.document.body.appendchild($button) $ieaddbutton = $button ENDFUNCTION ;****************** FUNCTION IESetBackColor($window,$color) $window.document.body.bgcolor = $color ENDFUNCTION ;****************** FUNCTION IEInputBox($title, Optional $prompt, optional $ok, optional $cancel) DIM $click, $html, $window, $status, $click, $button, $box
IF NOT $prompt $prompt = "Please enter your password." ENDIF IF NOT $ok $ok = "OK" ENDIF IF NOT $cancel $cancel = "Cancel" ENDIF
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$window = IECreateWindow($title,100,100,300,130,$html) WHILE $window.busy AND $window.readystate <> 4 AND @error = 0 LOOP $window.document.getelementbyid("input").focus $status = $window.document.getelementbyid("status") $click = $window.document.getelementbyid("input") $button= 0 $box=0 WHILE @error = 0 AND $button = 0 $button=$status.value $box=$click.value SELECT CASE $button = "1" $ieinputbox = $box CASE $button = "2" $ieinputbox = "Cancel" ENDSELECT LOOP $window.quit $window="" ENDFUNCTION
Kent [ 27 June 2002, 01:20: Message edited by: kdyer ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1662 anonymous users online.
|
|
|