Jump to content

COM reference


Recommended Posts

Hi guys, running into an issue where autoit itself is crashing, not the script. I have a vbscript (COM reference) that works, and I am trying to convert it to an autoit script. Here are the details:

set QPST = CreateObject("QPSTAtmnServer.Application")
   set SelectedPort = QPST.GetSelectedPort
 set Provisioning = SelectedPort.Provisioning


   Data = Provisioning.GetNVItem(Item)

My autoit code:

$oQPST = ObjCreate("QPSTAtmnServer.Application")     

$SelectedPort = $oQPST.GetSelectedPort

  $Provisioning = $SelectedPort.Provisioning
$item= 0
 $Provisioning.GetNVItem($Item)

When the script gets to "$Provisioning.GetNVItem($Item)" , I get an unhandled autoit exception. Any ideas are much much appreciated !!

Edited by richietheprogrammer
Link to comment
Share on other sites

You need COM error handler running to capture errors for you.

Add this at top of your script:

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You need COM error handler running to capture errors for you.

Add this at top of your script:

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc

Thanks for this. The same thing happens, and console write:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\user\Desktop\com.au3"

>Exit code: 0 Time: 3.507

after I choose to not debug the exception.

Link to comment
Share on other sites

Thanks for this. The same thing happens, and console write:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\user\Desktop\com.au3"

>Exit code: 0 Time: 3.507

after I choose to not debug the exception.

Your exit code is 0. :) What exception?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Your exit code is 0. :) What exception?

I hope this is not asking for too much, but I did a screencapture little avi, that you can get from

http://www.megaupload.com/?d=4J3RNOS6

this way we are on the same page. But to answer your confusion, the unhandled exception shows in a separate window. Please see video. I appreciate all your help!

Link to comment
Share on other sites

Since you said there is a debug button, it seems it is a crash reported by windows. Did you already try the new beta? [out]-Parameters like $item in your example arent't supported in the current stable yet.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Since you said there is a debug button, it seems it is a crash reported by windows. Did you already try the new beta? [out]-Parameters like $item in your example arent't supported in the current stable yet.

Yes, it is reported by windows. Can you please guide me in the right direction to get the new beta? What are you saying does make sense in this case, and I hope the beta will fix this. :)
Link to comment
Share on other sites

Your video shows nothing particularly useful.

Post the exact code you run.

Post the whole console output.

Sorry about this. My code is the same mentioned in the original post. And the console output:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\user\Desktop\com.au3"

>Exit code: 0 Time: 8.262

which is not informative :)

Edited by richietheprogrammer
Link to comment
Share on other sites

Sorry about this. My code is the same mentioned in the original post. And the console output:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\user\Desktop\com.au3"

>Exit code: 0 Time: 8.262

which is not informative :)

The code in the first post doesn't have 46th nor 49th line.

Post the freaking code you run.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Please disregard the first couple seconds in the video, as they are from another code, sorry to get you upset..

Oh, sorry is not enough mister.

Now you have to promise and do few things. Promise to use public transport, to support Green Peace, to recycle your cans, to reuse your plastic bags and condoms, to stop smoking, not to buy products that are harmful to the environment, to run and post the suggested code.

Then, you'll be forgiven.

(ehh, forget part about condoms)

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Oh, sorry is not enough mister.

Now you have to promise and do few things. Promise to use public transport, to support Green Peace, to recycle your cans, to reuse your plastic bags and condoms, to stop smoking, not to buy products that are harmful to the environment, to run and post the suggested code.

Then, you'll be forgiven.

(ehh, forget part about condoms)

hahaha you actually made me laugh :)

Link to comment
Share on other sites

Good. How does this make you feel?

Post the fucking code.

Post the fucking console output.

Not sure why you are saying this... here is beta's:

Code:

$oQPST = ObjCreate("QPSTAtmnServer.Application")     

$SelectedPort = $oQPST.GetSelectedPort

  $Provisioning = $SelectedPort.Provisioning()
$item= 0
 $Provisioning.GetNVItem($Item)

Console:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Program Files\AutoIt3\Beta\Examples\count-do.au3"

>Exit code: 0 Time: 3.357

And I got the unhandled exception the same way the video shows.

Link to comment
Share on other sites

Not sure why you are saying this... here is beta's:

Code:

$oQPST = ObjCreate("QPSTAtmnServer.Application")     

$SelectedPort = $oQPST.GetSelectedPort

  $Provisioning = $SelectedPort.Provisioning()
$item= 0
 $Provisioning.GetNVItem($Item)

Console:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Program Files\AutoIt3\Beta\Examples\count-do.au3"

>Exit code: 0 Time: 3.357

And I got the unhandled exception the same way the video shows.

And where is the COM error handler there?

How do you expect anyone to help you if you do that?

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

And where is the COM error handler there?

How do you expect anyone to help you if you do that?

COM error handler did not change anything when I tried it. I know the handler works because it worked on another script, but that appears to work when the function actually fails. What is happening in my case is that Autoit is crashing, and when I hit cancel to debug, the console is saying exit code 0. I found a similar issue, here:

Could this be that autoit doesnt support the "item" variable in this case, as stated previously? And how can i fix that? Any help is much appreciated.

Edited by richietheprogrammer
Link to comment
Share on other sites

It seems I was wrong with $item, I looked up "GetNVItem" and $item is no [out]-parameter. It was just a guess.

But I found some docs in which $provisioning is no IDispatch-interface, just IUnknwon. That could be a problem, too. Without the acutal object to examine and test, this is only a guessing game.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It seems I was wrong with $item, I looked up "GetNVItem" and $item is no [out]-parameter. It was just a guess.

You'll have to remove one line after another from your example until it does not crash anymore. Then you can tell us the exact command that causes the crash.

Thanks for this. I know already exactly where it is happening. It is in the following:

$data= $Provisioning.GetNVItem($Item)

So something about what you said earlier might be right, no?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...