How to draw above the Windows 8 Metro interface?

2019-05-30 16:48发布

问题:

I would like to draw graphics that will reside above all other interfaces, including Windows 8 new Home screen. How would you go about doing that? With Windows 7 and down, it would be as simple as showing a transparent fullscreen window above all else, but now since the desktop is separated from the rest of the operating system it is not possible anymore.

The reason is that I need to display two cursors independent of the Windows mouse cursor. I am developing a multi touch simulation software for a Wii Remote (using the sensor bar pointer), and for the moment I just set the cursor position and wakes it by shaking +1 and -1 pixels. But it interferes with the touching, so I have to disable it when using the touch simulation. It works for the moment, but I would like to add multi touch support so that you can zoom and rotate with the Wii Remote. The touch function is ready, but you would want to see cursors for when holding one touch point and choosing the other touch point with the Wii Remote, and while holding the first touch point the Windows cursor aren't able to move anywhere else because it sticks to the touch point.

I have seen how to draw directly to the screen by aquiring a Graphics object for the screen, but it does not work since it is completely unmanaged, so the graphics stay visible until something else refreshes the area.

So, any suggestions?

The project involved is called Touchmote and is available as source code and installable beta on touchmote.net.

回答1:

  1. Demand the UIAccess integrity level in application manifest by specifying UIAccess=”true” in the requestedPrivileges attribute.
  2. Make the window topmost (change the position via SetWindowPos or set the TopMost property in WinForms/WPF)
  3. Sign the application using a digital certificate that chains up to a trusted root in the local machine Trusted Root Certification Authorities certificate store.
  4. run directly (that is, not from a debugger) from a secure location in the file system. You can attach a debugger afterwards.

Note this make your application running elevated, you may have issues when you need to connect to your application from a lower integrity level.



回答2:

There is already an interface for what you're trying to do: Touch Injection. You can specify that you have contacts in range but not in contact with the screen, and a little circle will appear on the screen. You don't need to draw the circles yourself; the touch system will do it for you.