简体   繁体   中英

How to capture Alt + Tab

I want change ItemSource or something when pressing the Alt + Tab so how to do this. I have tried below the code but its not work in WPF:

void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Tab && (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
    {
        MessageBox.Show("CTRL + TAB trapped");
    }    
}

You need to hook into the Windows API to get access to the keyboard and intercept these calls. Check out the guidance given here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM