Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active March 19, 2018 18:27
Show Gist options
  • Save pervognsen/e2e8e5cf1dcc386fc13d5545900398a1 to your computer and use it in GitHub Desktop.
Save pervognsen/e2e8e5cf1dcc386fc13d5545900398a1 to your computer and use it in GitHub Desktop.

The goal is to be able to sketch directly on top of another foreground app with Milton.

To enter screen sketch mode, you launch Milton with a special command line switch. This would also be provided with a shortcut in the Windows Start Menu: In addition to the current "Milton" icon, there'd also be a "Milton Screen Sketch" icon.

When screen sketch mode is entered:

  1. Maximize window, set WS_EX_TOPMOST, and hide system title bar, frame and Milton's own menu.
  2. Implement this SO answer for DWM-accelerated OpenGL window transparency: https://stackoverflow.com/a/4055059
  3. Install a global keyboard hook to toggle whether Milton should be the foreground window. When it's in the foreground it can receive keyboard and tablet events as it usually would. SetForegroundWindow is restricted for security reasons, so this is only possible if a keyboard hook callback counts as the process "receiving the last input event". If this doesn't work, we can just use built-in Windows task switching via the task bar or alt-tabbing.

You'd probably want some additional convenience features as well:

  1. Ability to clear sketch non-destructively: hide current layer, then add new layer.
  2. As an extension of 1, take a screenshot (sans Milton's overlay) into a new layer, so you have a (non-flattened) record of both the screen as it was, and the overlaid sketch.
  3. A version of 1 and 2 that makes a copy of the current layer rather than starting a new layer. This lets you capture snapshots of the sketch at various stages of completion with the corresponding screenshots.
  4. To work in a true background tray mode, you'd want the initial and post-clear state to be quiescent except for the keyboard hook. Minimize or don't draw the transparent window (since it'll be blank) until the first time a draw command is sent after a clear.

You could do a solid MVP with only 1 and 2 and grow from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment