Aero peek API for Windows

I am trying to use the API for aero peek. With a lot of digging and searching, I came across this piece of code:

[DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)] internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint ); 

But I can’t make it work. I don’t know what parameters ... I tried some API interception tools, but this did not work. How can I find out how to properly name this API?

+8
windows api aero aero-peek
source share
4 answers

In the end, I decided it myself. I posted an article about it on my website: http://www.jesconsultancy.nl/tips-and-tricks/aero-apis.html . Unfortunately, this is in Dutch, so it explains a bit here:

  [DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)] internal static extern uint DwmpActivateLivePreview(uint switch, IntPtr hWnd, IntPtr c, uint d); DwmpActivateLivePreview(1, Handle, topmostWindowHandle, 1);//activate DwmpActivateLivePreview(0, Handle, topmostWindowHandle, 1);//deactivate 

The first parameter is for activating / deactivating the functionality of Aero Peek. The second parameter is the handle that Aero peek focuses on. The other two , which I have not yet been able to identify.

Edit: After some involvement in this API, I figured out the 3rd parameter. When setting the TopMost property of a form, the form is still sometimes displayed under the aero peek effect. If you pass a handle to this form, which should be on top of the peek effect as the 3rd parameter, and the TopMost property of your form is set to true, your form will be on top of the peek effect.

You can exclude a window from the Aero Peek effect. This is described here: http://huddledmasses.org/fun-with-pinvoke-and-aero-peek/

+4
source share

I know this is an older question, but the accepted answer is not complete.

The following is the correct use of the Aero Peek API.

  ///<summary> /// These flags are used in conjunction with the Aero Peek API. /// </summary> public enum PeekTypes : long { /// <summary> /// This flag is here only for completeness and is not used /// </summary> NotUsed = 0, /// <summary> /// Denotes that the Peek API is to operate on the desktop /// </summary> Desktop = 1, /// <summary> /// Denotes that the Peek API is to operate on a window. /// </summary> Window = 3 } /// <summary> /// This is the *Almighty* Aero Peek API! /// </summary> /// <param name="EM">True if we're going into peek mode; False if we're coming out of it.</param> /// <param name="PH">The handle of the window we want to put into peek mode; /// IntPtr.Zero if we're coming out of peek mode or peeking on the desktop.</param> /// <param name="C">The handle of the window calling the API method.</param> /// <param name="pT">One of the <see cref="PeekTypes"/> enum members. /// Pass <see cref="PeekTypes.Desktop"/> if you want to peek on the desktop and <see cref="PeekTypes.Window"/> if you want to peek on a window. <see cref="PeekTypes.None"/> is unused but, there for completeness.</param> /// <param name="hPN0">When going into or out of peek mode, always pass new IntPtr(32) for this parameter.</param> /// <param name="iFI0">When going into or out of peek mode, always pass 0x3244 for this parameter.</param> /// <returns></returns> [DllImport("dwmapi.dll", EntryPoint = "#113", CharSet = CharSet.Auto, PreserveSig = true, SetLastError = true, CallingConvention = CallingConvention.StdCall)] static extern int InvokeAeroPeek(bool EM, IntPtr PH, IntPtr C, PeekTypes pT, IntPtr hPN0, int x3244); 

I spent several months reverse engineering most of the cool Windows 7 taskbar APIs, and this is part of my results. Take it or leave it, this is the right way to use the Aero Peek API. My “research” was done in 2008, while Windows 7 was still in beta testing, and common pre-release versions were common. For those who can give a shit, this code should work on Windows 8. The following is a simple example:

 InvokeAeroPeek(enterPeekMode, target, caller, pType, new IntPtr(32), 0x3244); 

This code is agnostic of the processor, compile it as you want, and it will work anyway. Win32 and x64 are welcome.

+4
source share

Can you talk about what you are trying to do? Are you trying to invoke peek or support custom Aero peek in your own application?

if the latter you should refer to http://msdn.microsoft.com/en-us/library/ff819048(v=VS.85).aspx and the corresponding documentation.

+1
source share

I have bad news for everyone who really uses this undocumented feature. Windows 10 seems to have added an extra argument to the end. This probably means that your code that works fine under Win7 will probably crash under Win10, because the stack pointer will get confused after calling this function. In addition, it is likely that calling this function with a missing stack argument will cause Win10 to eliminate the bad pointer during the call itself.

I used the following definition.

 typedef HRESULT (__stdcall *DwmpActivateLivePreview)(BOOL peekOn, HWND hPeekWindow, HWND hTopmostWindow, UINT peekType1or3, UINT_PTR newForWin10); 

I just passed zero in this new argument. By running 64-bit code under Win10 64bit, I was able to activate Aero Peek using the arguments, as described in other answers on this page. Running 32-bit code under Win10 64bit, I got the same error 0x80070018 that I received when running 32-bit code under Win7 64bit.

+1
source share

All Articles