Neatware Header
Home   Products   Solutions   Partners   Store   Company   

COM Examples

Below examples demonstrate how to launch a Windows application and control them.

  • Launch IE with URL
  • This example launches IE and visit Neatware website.

    package require tcom
    

    create an IE object app, set it visible, and navigate it.

    set app [::tcom::ref createobject \\
    	"InternetExplorer.Application"]
    $app Visible 1; $app Navigate "http://www.neatware.com" 
    

    release app object

    ::tcom::release $app
    
  • Use Windows Script Hosting
  • This example demonstrates how to use WSH to control the action of the Calculator. load tcom, close Tk window, and hide the errors.

    package require tcom
    catch {wm withdraw .}
    

    open WinShell object and run Calculator program in windows.

    set wshell [::tcom::ref createobject WScript.Shell]
    $wshell Run "calc"
    

    active Calculator, wait 2 seconds, input digital 9, /, and 7, and see the result.

    $wshell AppActivate "Calculator"; after 2000
    $wshell SendKeys "9{/}"; after 2000
    $wshell SendKeys "7"; after 2000
    $wshell SendKeys "~"; after 2000
    $wshell SendKeys "%\\"
    

    close object

    ::tcom::release $wshell
    


Google
  Web Neatware.com