Jump to content

Recommended Posts

Posted

Hi,

I'm looking for a way communicate with a ocx control and not sure if this can be donw with autoit.

Please let me know if this is possible and any pointers would be great.

many thanks

Posted

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.

Posted

@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

Posted

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?)

Posted (edited)

@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
Posted

thanks for the tips ptrex, I'll try them now.

The OCX is used by POS (Point of Sale) software to access a receipt printer. I need to communicate with the printer via the OCX to print my own stuff.

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
×
×
  • Create New...