Has anyone implemented PC-DMIS event handler in Python?
I tried both win32com.client.getevents and win32com.client.DispatchWithEvents, but I got the TypeError.
- win32com.client.getevents
TypeError: Objects of type 'CDispatch' can not be converted to Unicode solution - win32com.client.DispatchWithEvents
TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
The equivalant C# code is as follows.
Any of your reply is welcome.
Thanks and Best Regards,
Aki
using PCDLRN; public PCDLRN.ApplicationObjectEvents pcdmisEvents; namespace Automation { /// <summary> /// An empty window that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainWindow : Window { private void main() { var objDmisApp = Type.GetTypeFromProgID("PCDLRN.Application"); var objPCDMIS = Activator.CreateInstance(objDmisApp) as PCDLRN.Application; objPCDMIS.Visible = true; objPCDMIS.Maximize(); objPCDMIS.ErrorDialogEnabled = 0; //Add events pcdmisEvents = objPCDMIS.ApplicationEvents; pcdmisEvents.OnStartExecution += pcdmisEvents_OnStartExecution; pcdmisEvents.OnEndExecution += pcdmisEvents_OnEndExecution; //TO DO } private void pcdmisEvents_OnStartExecution(PartProgram PartProg) { Debug.WriteLine("pcdmisEvents_OnStartExecution"); } private void pcdmisEvents_OnEndExecution(PartProgram PartProg, int TerminationType) { Debug.WriteLine("pcdmisEvents_OnEndExecution"); } } }