How to determine if Aero Peek is on

I am trying to figure out how to determine if the Windows Aero Peek desktop is turned on . In particular, I need to determine if my window contents are displayed as a frame with a transparent background. I know that I can exclude my window from Aero Peek, but this is not what I need at this moment.

TIA

+3
source share
3 answers

your desktop will enter this "Aero Peek" mode when the user looks in the windows by hovering over the icons on the taskbar. You can use the event event window to track if the Task Switcher " object is displayed , in combination with the DWM mode on it, tell if the user is viewing the window. Below is the application I made to test this idea (C ++, tell me if there is a problem converting it to C #).

#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <objbase.h>
#include <Oleacc.h>
#include <iostream>

#define THREAD_MESSAGE_EXIT     WM_USER + 2000

HWINEVENTHOOK eventHook;
HWND taskSwitcherHwnd = 0;

// process event
void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND hwnd, 
                             LONG idObject, LONG idChild, 
                             DWORD dwEventThread, DWORD dwmsEventTime)
{
    if (event == EVENT_OBJECT_SHOW) 
    {
        IAccessible* pAcc = NULL;
        VARIANT varChild;       
        HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);  
        if (hr == S_OK && pAcc != NULL)
        {
            BSTR accName;
            pAcc->get_accName(varChild, &accName);
            if (wcscmp(accName, L"Task Switcher")==0)
            {
                std::cout << "Aero Peek on\n";
                taskSwitcherHwnd = hwnd;
            }
            SysFreeString(accName);
            pAcc->Release();
        }
    }
    else if (event == EVENT_OBJECT_HIDE && taskSwitcherHwnd!=0 && taskSwitcherHwnd==hwnd)
    {
        std::cout << "Aero Peek off\n";
        taskSwitcherHwnd = 0;
    }
}

// thread proc for messages processing
// needed for event hook to work
DWORD WINAPI TreadProc(LPVOID n)
{
    std::cout << "InitializeEventHook\n";
    CoInitialize(NULL);
    eventHook = SetWinEventHook(
        EVENT_OBJECT_SHOW, EVENT_OBJECT_HIDE,   
        NULL, HandleWinEvent, 0, 0, 
        WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);   

    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (msg.message==THREAD_MESSAGE_EXIT) 
        {
            break;
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    std::cout << "ShutdownEventHook\n";
    UnhookWinEvent(eventHook);
    CoUninitialize();
    return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "Detect Aero Peek\n";

    DWORD threadId;
    int value = 0;
    HANDLE hThread = CreateThread( NULL, 0, TreadProc, &value, 0, &threadId);

    char a;
    std::cin >> a;

    PostThreadMessage(threadId, THREAD_MESSAGE_EXIT, 0, 0);
    WaitForSingleObject(hThread, 10000);
    CloseHandle(hThread);

    return 0;
}

hope this helps, believes

+2
source

Is that what you are after?

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern bool DwmIsCompositionEnabled();

    public bool IsAeroActive()
    {
        // Check if Aero is enabled;
        if (DwmIsCompositionEnabled())
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        bool aeroEnabled = IsAeroActive();

        if (aeroEnabled)
        {
            MessageBox.Show("Aero is enabled.");
        }
        else
        {
            MessageBox.Show("Aero is disabled.");
        }
    }
+3
source

Windows, Aero Peek

\ HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM

DWORD EnableAeroPeek, :

1 = 0 =

0 1, , AeroPeek.

# - :

Using Microsoft.Win32;

...

RegistryKey AeroPeek = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\DWM", true);
       if ((int)AeroPeek.GetValue("EnableAeroPeek") == 1)
        {
            MessageBox.Show("Aero Peek is ON");
        }
        else MessageBox.Show("Aero Peek is OFF");

, Aero Peek.

0

All Articles