Jump to content

can I communicate with ocx controls?


 Share

Recommended Posts

I've can connect with the object using: $oOpos = ObjCreate("OPOS.POSPrinter");

But is there a way send functions?

For example in the docs for the OCX Control, there is a function like: PrintImmediate(PTR_S_JOURNAL, 'hello');

I've attempted to use: $oOpos.PrintImmediate(PTR_S_JOURNAL, 'hello'); - but get an error.

Is it possible to pass functions to the object?

Sorry for the questions, I've not use AutoIt for a while and never used it to communicate with thried part OCX controls.

Link to comment
Share on other sites

@stuartc1

I don't know this specific OCX what it does.

But looking at the Error syntax you mentioned the error is related to the following :

1. $oOpos.PrintImmediate(PTR_S_JOURNAL, 'hello'); -> should be between "PTR_S_JOURNAL" or

2. $oOpos.PrintImmediate(PTR_S_JOURNAL, 'hello'); -> should be a Variable / constant $PTR_S_JOURNAL

I hope this helps

regards,

ptrex

Link to comment
Share on other sites

thanks ptrex for your suggestion, I updated it to include the quotes, but it still failed. I guess the problem is with the control.

The error I get is: 'The requested action with this object has failed'

Is there a generic way to request exposed methods on an object? (is there a way to find out which methods an object supports?)

Link to comment
Share on other sites

@stuartc1

Yes there is. In my signature you will find a Typlib browser.

But unfortunately is is still in a Beta stage.

Give it a try.

As will you can add the COM Error event routine in you script

; Initialize error handler 
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Your code goes here


;------------------------------ This is a COM Error handler --------------------------------
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

I hope this will get you started.

BTW what does the OCX do exactly ?

regards

ptrex

Edited by ptrex
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...