Disable alt key temporary c#
<p>I'm searching a way to disable alt and ctrl key input while I'm pressing it.
I'm actually developping a Macro Configurer and when I press my macro (for example Alt+Ctrl+NumPad0) and I want that the keys H+E+L+L+O are sent, it won't work because I'm pressing Alt. The computer probably tries to execute unknown shortcuts for Alt+Ctrl+H, Alt+Ctrl+E ... 
So I want that when I press my macro and the program detects I pressed it, it disable temporary alt while the output keys are sent, and enable again Alt when it's finished.
I use a LowLevelKeyboardProc to detect when i press a key, but I can't prevent the Alt pressing because i'm actually pressing it to execute my macro.</p>

<p>//The code from my form</p>

<pre><code>private void Listener_OnKeyUp(object sender, KeyUpArgs e)
{
    KeyAction.RemoveKeyDown(e.KeyUp);
}


private void Listener_OnKeyPressed(object sender, KeyPressedArgs e)
{
    try
    {
        KeyAction.PutKeyDown(e.KeyPressed);
        foreach (MacroEntree macro in macros)
        {
            if (macro.Activated)
                if (macro.Action != null)
                    if (macro.isMacroDown())
                    {
                        listener.OnKeyPressed -= new EventHandler&lt;KeyPressedArgs&gt;(Listener_OnKeyPressed);
                        new Thread(delegate ()
                        {
                            while (IsAltCtrlDown()) ;
                            macro.ExecuteAction();
                            Thread.Sleep(100);
                            listener.OnKeyPressed += new EventHandler&lt;KeyPressedArgs&gt;(Listener_OnKeyPressed);

                        }).Start();
                    }
        }
    }
    catch (Exception ex)
    {

        MessageBox.Show("Erreur : " + ex.Message);
    }
}
private bool IsAltCtrlDown()
{
    if (KeyAction.isKeyDown(Key.LeftAlt) || KeyAction.isKeyDown(Key.RightAlt))
        return true;
    if (KeyAction.isKeyDown(Key.LeftCtrl) || KeyAction.isKeyDown(Key.RightCtrl))
        return true;
    return false;
}


//the code from my class that checks if the macro is down
public class KeyAction
{
   static List&lt;Key&gt; keyDown = new List&lt;Key&gt;();

    public static bool isKeyDown(Key k)
    {
        return keyDown.Contains(k);
    }
    public static void PutKeyDown(Key k)
    {
        if (!keyDown.Contains(k))
            keyDown.Add(k);
    }
    public static void RemoveKeyDown(Key k)
    {
        keyDown.Remove(k);
    }
</code></pre>

<p>}</p>