Toggle state in c# - wpf
I want to make a function to work in toggle(switch) mode when i press a
key and i really can't figure how to do it. I tried lots of ways and only
the "RegisterHotKey" method is working fine. But "RegisterHotKey" is
overwriting the mapped key from the game and this is not what i need. So
i'm trying to use "GetKeyState". The code below it's only working for one
position no matter what i change...:
private void mw_KeyDown(object sender, KeyEventArgs e){
    bool toggle = true;
    bool sw = (toggle = !toggle);
    int tog = (GetKeyState(Key.Tab));
    if ((tog & 1) == 1)
    {
       if (sw)
       {
            System.Windows.MessageBox.Show("go to second position...!");
       }
    }
    else
    {
        System.Windows.MessageBox.Show("go to first position...!");
    }
}
Any idea or suggestion how can i do this ?
Thank you,
 
No comments:
Post a Comment