如何让焦点回到透明(启用点击)Window

How to get focus back on transparent (ClickThrough enabeled) Window

我正在开发一个 window 最初是透明的应用程序,然后在按键时(比如 shift+tab)window 应该是 不是 ClickThrough。我用来获取 ClickThrough 的代码如下:

_hwnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, 
            TEXT("Example"), 
            title, WS_BORDER,
            GetSystemMetrics(SM_CXSCREEN) / 2 - _width / 2,
            GetSystemMetrics(SM_CYSCREEN) / 2 - _height / 2,
            _width, _height,
            NULL, NULL,
            NULL, NULL);
int opacity = 70;
SetLayeredWindowAttributes(_hwnd, 0, (255 * opacity) / 100, LWA_ALPHA); 

现在,有什么解决方法可以 Not ClickThrough?我 google 它但从未找到任何一个。

是的,我已经使用注册 HotKeys 完成了此操作:WndProc 如下:

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    switch (message)
    {
    //break;
    case WM_HOTKEY:
    {
        switch (wparam)
        {
        case 1:// Close Window
            PostQuitMessage(0);
            break;
        case 2://Disable ClickThrough
            SetWindowLong(hwnd, -20, WS_EX_LAYERED); //-16 for window style
            break;
        case 3://enable ClickThrough
            SetWindowLong(hwnd, -20, WS_EX_LAYERED | WS_EX_TRANSPARENT); 
            break;
        }
    }
    break;
    case WM_CLOSE:
    {
        DestroyWindow(hwnd);
        return 0;
    }
    break;
    default:
        return DefWindowProc(hwnd, message, wparam, lparam);
    }


}

注册热键如下:

RegisterHotKey(_hwnd, 1, MOD_SHIFT, 0x43); //shift + c
RegisterHotKey(_hwnd, 2, MOD_SHIFT, 0x44); //shift + d
RegisterHotKey(_hwnd, 3, MOD_SHIFT, 0x45); //shift + e