質問者
Windows8でのAlt+Tabのボタン化

質問
-
はじめまして、よろしくお願いします。
以下のような内容のプログラムで、ボタン押下時にAlt+Tabを押す内容でプログラム切り替えのスイッチを作成しております。
Windows XPでは動作していたのですが、Windows 8にした場合、全く動かなくなってしまいました。
キーボードでalt+tabの場合の動作は変わらないので、なぜだか良く解りません。
どなたかご存じ、もしくは解決された方おりませんでしょうか?
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; namespace AltTab { public partial class Form1 : Form { public const int SW_HIDE = 0; public const int SW_NORMAL = 1; public const int SW_SHOWMINIMIZED = 2; public const int SW_SHOWMAXIMIZED = 3; public const int SW_SHOWNOACTIVATE = 4; public const int SW_SHOW = 5; public const int SW_MINIMIZE = 6; public const int SW_SHOWMINNOACTIVE = 7; public const int SW_SHOWNA = 8; public const int SW_RESTORE = 9; public const int SW_SHOWDEFAULT = 10; byte VK_MENU = 0x12; byte VK_TAB = 0x09; uint KEYEVENTF_EXTENDEDKEY = 0x01; uint KEYEVENTF_KEYUP = 0x02; public Form1() { InitializeComponent(); } [DllImport("user32.dll")] public static extern uint keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { ShowWindow(this.Handle, SW_RESTORE); SetForegroundWindow(this.Handle); keybd_event(VK_MENU, 0xb8, 0, (UIntPtr)0); //Alt Press keybd_event(VK_TAB, 0x8f, 0, (UIntPtr)0); // Tab Press keybd_event(VK_TAB, 0x8f, KEYEVENTF_KEYUP, (UIntPtr)0); // Tab Release keybd_event(VK_TAB, 0x8f, 0, (UIntPtr)0); // Tab Press keybd_event(VK_TAB, 0x8f, KEYEVENTF_KEYUP, (UIntPtr)0); // Tab Release keybd_event(VK_TAB, 0x8f, 0, (UIntPtr)0); // Tab Press keybd_event(VK_TAB, 0x8f, KEYEVENTF_KEYUP, (UIntPtr)0); // Tab Release keybd_event(VK_MENU, 0xb8, KEYEVENTF_KEYUP, (UIntPtr)0); // Alt Release } } }