Jump to content
Sign in to follow this  

Problems exiting script when using COM objects

Recommended Posts


I am having problems exiting a script when using COM objects. When i close the GUI, it closes, but i have to press "stop executing" or CTRL-BREAK in Scite manually to really exit it. When i uncomment the lines where i delete the objects before the exit-command, the script hangs and the gui doesnt even close.

#include <GUIConstants.au3>

$oComMgr = ObjCreate("MBTrading.MbtComMgr")
$oQuotes = ObjCreate("MBTrading.MbtQuotes")
$oOrders = ObjCreate("MBTrading.MbtOrderClient")

$gui = GUICreate("MBTSDKtest", 300,150,-1,-1,-1,$WS_EX_TOPMOST)
$buttontest = GUICtrlCreateButton("Test", 10, 50, 80, 25)

GUISetState(@SW_SHOW, $gui)

While 1
    $msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
        ;$oComMgr = 0
        ;$oQuotes = 0
        ;$oOrders = 0
        Case $msg = $buttontest
            $t1 = IsObj($oComMgr)
            $t2 = IsObj($oQuotes)
            $t3 = IsObj($oOrders)
            MsgBox(0,0,"ComMgr: " & $t1 & @CRLF & "Quotes: " & $t2 & @CRLF & "Orders: " & $t3)

Any hints appreciated!

Share this post

Link to post
Share on other sites

Based on the code supplied I can see no reason taht your script would hang, sorry.

You may know the following already, but I'll toss it out in case it is related:

Setting the object variable to null simply severs your attachment to the object and decrements the global reference count for that object. If instantiating the object starts another process that increments the reference count, the objects are not destroyed. You should check to see if the objects have some sort of a quit or rundown method.


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...