Jump to content

C# OBJ/COM example conv to Autoit trouble


laffo16
 Share

Recommended Posts

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 by laffo16
Link to comment
Share on other sites

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 by laffo16
Link to comment
Share on other sites

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 by LaCastiglione
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...