antfu / live-draw

A tool allows you to draw on screen real-time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global shortcut for recover

Svk1190 opened this issue · comments

The keyboard shortcut R is meant to release/recover control of drawing. However, it is not helpful when we try to recover control. Suppose that the Livedraw application is visible on top of a pdf document, but we are not currently annotating anything. Instead, we are currently interacting with the document, for example, we might be scrolling through the pages of a pdf document. Now we wish to recover the control of drawing and begin to annotate. If we click on the R button, nothing happens. This is because the document is still the currently focused window. The R input is passed to the document instead of passing it to the Livedraw application. Hence, we cannot recover control of drawing.

Now if we switch to the Livedraw application from the Taskbar or by using Alt+Tab, then clicking the R button immediately activates the drawing mode. But this is inconvenient.

So we require that Livedraw is constantly listening to all keystrokes, and whenever we type the recover keystroke, it activates the drawing mode immediately. The R button is not a good keystroke for recovering control. This is because we might be typing in a Word document, where typing the letter R happens frequently. So we need some slightly esoteric key combination, such as Ctrl+shift+R or Ctrl+E or something else, which is typically not used by other applications.

The recovery shortcut is the only one that needs to be global (meaning that Livedraw listens for this keystroke even if it is not in focus). All other shortcuts are used when the Livedraw application is in focus, and hence all other shortcuts can be local.

Duplicate #17

BTW thanks for describing the issue in such great detail. I am aware of the issue and I was trying to make hotkeys to solve these issues but unfortunately I am not having enough time in my hand.

If you want to work on this issue, you are most welcome to do so.

I did not notice the existing issue. Also, I am not a developer. Sorry to disappoint you.

Just started using LiveDraw, and very impressed. Thanks to the devs! Definitely the easiest way to implement telestration w/ video (OBS Studio, Zoom, etc.).

Went looking for keyboard shortcuts as am finding it hard to find the right button for recover/release, plus often prefer keyboard while recording...

I use AutoHotkey for many other similar situations, and seeing the difficulty in implementing natively here, will attempt something using the following approach.

  • autohotkey listens for Alt + R (or whatever meta key + R combo).
  • upon receiving Alt + R AutoHotkey 1.) activates LiveDraw, giving it focus, and 2) sends the R keystroke
  • this will have the overall workflow effect that 1.) R will "release" control if LiveDraw is active and 2.) Alt + R will "recover" control if LiveDraw is not in control (i.e. grabbing all the keystrokes while active)
  • regular R will be R when LiveDraw not active

Probably need an "activate if not already active" statement to AHK for this exact behavior if I only ever wanted Alt + R to activate. Otherwise it will likely function as an "alternate global toggle", since without the "activate if not active" directive, it would end up just sending the R to an already active LiveDraw...

Sorry, am a dev, but don't know C#. AutoHotkey is C++, and on github, so possible you may get some keystroke listening ideas there. Seems like the basic approach I describe might work, where "recovering" control happens only when R plus a meta character is engaged (tho hopefully the exact combo would be configurable :)

Will post my AutoHotkey implementation here when done as I understand the devs are busy and probably not about to port C++ AHK code to LiveDraw to expand it's shortcut assignment abilities.

Thanks again for the great code!
🙏

So AHK makes this work perfectly. This code uses ctrl + alt + r to ensure the fewest possible overlaps with apps that might be running (while LiveDraw isn't intercepting all keystrokes to apps underneath):

(sorry, the MD backticks are mangling the code formatting and removing all carriage returns, pasting as plain text)

AHK code below; add to AutoHotkey.ahk after installing app from https://github.com/AutoHotkey/AutoHotkey

;### LiveDraw Global keystroke; Release/Recover toggle
DetectHiddenWindows, On
SetTitleMatchMode, 2
#IfWinExist, LiveDraw Dev
{
; ctrl + alt + r
^+!r:: ; Release/Recover LiveDraw onscreen drawing control
WinActivate ;
Send r;
return
}

With AHK and this code snippet, Ctrl + Shift + Alt + R reliably toggle LiveDraw Release/Recover. And if you still hit just plain R while LD is active, that will behave as previously and Release...