Hi, Carsten,
We are unable to support further with this, you will need to find a solution yourself as our licensing model is not designed for the type of behaviour you wish to use, you can also find 3rd party licensing software that may help.
I ran the code above and the welcome panel displayed and when I closed it I then pressed Alt+A and it was captured, so it was working fine, your implementation does not work with cTrader, you need to use Chart events as I have used above.
I understand what you are trying to do now, it looks like there is a limitation with the licensing code that prevents standard key events after it has been displayed.
Possible Solution
A better solution would be not to capture the event when there is an incoming tick of data in the calculate method as this may have a delay for the user it is better to capture the event as shown in the example above so that when the user presses a modifier key it captures it. Your solution is to capture only when the key is pressed, you can do this by setting a flag and when the key is pressed the flag is true.
The solution below will work when the user presses Alt+A it runs and when they press Alt+A again it stops, this could be a workaround to your problem, so instead of keeping the key pressed, they use keys to start and stop the feature you wish to use. I am sure they are other ways to do this, but unfortunately, you have a limitation with the licensing solution.
.
using cAlgo.API;
using System;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
internal class RRTool : Indicator
{
[Parameter("Modifier Key", DefaultValue = ModifierKeys.Alt)]
public ModifierKeys ModifierKeyAlt { get; set; }
[Parameter("Key", DefaultValue = Key.A)]
public Key KeyA { get; set; }
public override void Calculate(int index)
{
}
private bool _isKeypress = false;
private bool _validationComplete = false;
protected override void Initialize()
{
Chart.AddHotkey(() => KeyHandler(), KeyA, ModifierKeyAlt);
try
{
if (!_validationComplete)
{
using (WelcomePanel wp = new WelcomePanel())
{
wp.ShowDialog();
if (wp.StopRobot)
{
wp.Dispose();
return;
}
wp.Dispose();
_validationComplete = true;
}
}
}
catch
{
return;
}
}
private void KeyHandler()
{
if (!_isKeypress)
{
Chart.DrawStaticText("keys", DateTime.Now.ToString() + "Alt A Key pressed", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Red);
_isKeypress = true;
}
else
{
Chart.RemoveObject("keys");
_isKeypress = false;
}
}
}
}