laffo16 Posted January 23, 2012 Share Posted January 23, 2012 (edited) Hi guys, Having differculty trying to convert the c# example below into autoit, i just cant wrap my head around how to use Events. hopefuly someone can point me in the right direction. C# Example (ive trimmed out namespace & public): using BettingAssistantCom.Application; private ComClass ba; public delegate void pricesUpdatedDeleg(); public Form1() { InitializeComponent(); ba = new ComClass(); ba.pricesUpdated += new ComClass.pricesUpdatedEventHandler(ba_pricesUpdated); } public void ba_pricesUpdated() { pricesUpdatedDeleg deleg = new pricesUpdatedDeleg(this.pricesUpdated); this.Invoke(deleg); } public void pricesUpdated() { try { Object[] prices; listBox1.Items.Clear(); prices = ba.getPrices(); foreach (Price priceItem in prices) { listBox1.Items.Add(priceItem.selection.PadRight(50, ' ') + "t" + priceItem.backOdds1); } } catch { } } Cutting it down, we have private ComClass ba; // create com obj ba.pricesUpdated += new ComClass.pricesUpdatedEventHandler(ba_pricesUpdated); // create the event handler public void ba_pricesUpdated() {} // the function which is called by the hanlder sorry i cant really provide i good autoit example to work upon, this is what i have (doesnt work) Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass") ; <- this part is ok. ObjEvent("BettingAssistantCom.Application.pricesUpdatedEventHandler", "ev_") While 1 Sleep(500) WEnd Func ev_pricesUpdatedEventHandler() MsgBox(0, "", 1) EndFunc Edited January 23, 2012 by laffo16 Link to comment Share on other sites More sharing options...
laffo16 Posted January 23, 2012 Author Share Posted January 23, 2012 ne ideas on this guys, tried all sorts of things, just dont know how to convert this to autoit ba.pricesUpdated += new ComClass.pricesUpdatedEventHandler(ba_pricesUpdated); // create the event handler Link to comment Share on other sites More sharing options...
laffo16 Posted January 24, 2012 Author Share Posted January 24, 2012 (edited) final bump, ive still no joy in converting the above line into autoit. not making any ground on this, would appreciate ne help. have also tried the ObjEvent example but it returns an autoit com error number: -2147352570. not sure if this is related to my issues. i feel i need this ba.pricesUpdates += ..... line to work in order to tell bettingassistant to start producting events for autoit ObjEvent to work. i can provide a VB example if it may help. anyone know howto do this in autoit? i boiled the c# down, using BettingAssistantCom.Application; new ComClass().pricesUpdated += new ComClass.pricesUpdatedEventHandler(ba_pricesUpdated); public void ba_pricesUpdated() { MessageBox.Show("events are gogo"); } Edited January 24, 2012 by laffo16 Link to comment Share on other sites More sharing options...
laffo16 Posted January 29, 2012 Author Share Posted January 29, 2012 (edited) help, bump! edit: have pm'ed the author of betting.assistant, hes unsure wether event comminication is done via 'dispatch' type. Edited January 29, 2012 by laffo16 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 29, 2012 Share Posted January 29, 2012 (edited) Well, I think you're using you're ObjEvent wrong. Try something along these lines Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass") ; <- this part is ok. ObjEvent($BAcom, "ev_") While 1 Sleep(500) WEnd Func ev_pricesUpdatedEventHandler() MsgBox(0, "", 1) EndFunc Edited January 29, 2012 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now