** Example 1: ** ====== package require twapi set bIEFound 0 #-- Is IE already running? set app [ twapi::comobj Shell.Application ] set wnds [ $app Windows ] set nIndex 0 set nLength [ $wnds Count ] while { $nIndex < $nLength } { set itm [ $wnds Item $nIndex ] set name [ $itm FullName ] set name [ string tolower $name ] if { [ string first "iexplore.exe" $name ] >= 0 } { set bIEFound 1 set ie $itm set szUrl [ $ie LocationURL ] set szUrl [ string tolower $szUrl] #-- This is sometimes troublesome, if IE already running while { [ $ie Busy ] } { puts -nonewline "." flush stdout $ie Stop after 250 } $ie Navigate "http://wiki.tcl.tk/_/search" break } incr nIndex } if { $bIEFound } { #-- Yes; make it visible set w [ $ie HWND ] set wIE [ list $w HWND ] twapi::show_window $wIE -normal -activate twapi::set_focus $wIE $ie Visible 1 } else { #-- No; start it set ie [ twapi::comobj InternetExplorer.Application ] $ie Visible 0 set szUrl "http://wiki.tcl.tk/_/search" $ie Navigate $szUrl $ie Visible 1 set w [ $ie HWND ] set wIE [ list $w HWND ] } while { [ $ie Busy ] } { puts -nonewline "." flush stdout after 250 } set doc [ $ie Document ] while { [ $doc readyState ] != "complete" } { after 250 } set body [ $doc body ] set inputs [ $body getElementsByTagName "input" ] set index 0 set length [ $inputs length ] while { $index < $length } { set input [ $inputs item $index ] set name [ $input name ] if { [ string compare $name "S" ] == 0 } { $input value "twapi" $input focus $input Send "{ENTER}" break } incr index } set buttons [ $body getElementsByTagName "input" ] set index 0 set length [ $buttons length ] while { $index < $length } { set button [ $buttons item $index ] set name [ $button name ] if { [ string compare $name "submit" ] == 0 } { $button focus after 250 $button click after 250 break } incr index } ======