Maybe some of you have trouble how they should create an event.
event = do my stuff if the event happens.
1. We choose an event. -> http://www.archebuddy.com/API/html/210785147.htm
We will try to create a hotkey which can be done by the event "onKeyDown"
onKeyDown uses the delegate CoreInternal.KeyboardEvent ->http://www.archebuddy.com/API/html/586342424.htm
2. Create a function which will be called
In the api we can see that the delegate looks like this
This means our "get called method" should be look like
3. Register the event
You still know the name of the event? "onKeyDown"
Okay then what name did you gave your "get called method"?
If you did the same like me then the event name is "onKeyDown" and the "get called method" is "KeyboardEvent"
You register it with
pretty simple.
4. The results
Every time the event "onKeyDown" happens your method will be called.
Here an complete example, feel free to copy and Try to press F8
Have a nice day
event = do my stuff if the event happens.
1. We choose an event. -> http://www.archebuddy.com/API/html/210785147.htm
We will try to create a hotkey which can be done by the event "onKeyDown"
onKeyDown uses the delegate CoreInternal.KeyboardEvent ->http://www.archebuddy.com/API/html/586342424.htm
2. Create a function which will be called
In the api we can see that the delegate looks like this
Code:
public delegate void KeyboardEvent(
Keys key,
bool isCtrlPressed,
bool isShiftPressed,
bool isAltPressed
)
This means our "get called method" should be look like
Code:
void KeyboardEvent(Keys key,bool isCtrlPressed,bool isShiftPressed,bool isAltPressed)
{
//Do stuff here
}
You still know the name of the event? "onKeyDown"
Okay then what name did you gave your "get called method"?
If you did the same like me then the event name is "onKeyDown" and the "get called method" is "KeyboardEvent"
You register it with
Code:
onKeyDown += KeyboardEvent
4. The results
Every time the event "onKeyDown" happens your method will be called.
Here an complete example, feel free to copy and Try to press F8

Code:
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
namespace YourNamespace
{
public class YourClass : Core
{
public static string GetPluginAuthor()
{
return "";
}
public static string GetPluginVersion()
{
return "";
}
public static string GetPluginDescription()
{
return "Event Example";
}
void KeyboardEvent(Keys key,bool isCtrlPressed,bool isShiftPressed,bool isAltPressed)
{
if (key == Keys.F8)
{
Log("Your pressed F8, Congratulations!")
}
}
public void PluginRun()
{
onKeyDown += KeyboardEvent;
while (true)
Thread.Sleep(50);
}
}
}
Have a nice day

Last edited: