dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
388 stars 75 forks source link

Set DPI awareness automatically when dragonfly is imported #305

Closed drmfinlay closed 4 years ago

drmfinlay commented 4 years ago

Closes #289.

This is @wolfmanstout's patch (https://github.com/dictation-toolbox/dragonfly/commit/c3a1b1e306a720e5b2e1ad3b8c5c3d4e1e30c668) with a safety check for older versions of Windows, plus some logging if setting the process DPI awareness fails (E_INVALIDARG and E_ACCESSDENIED are handled). I have also updated the relevant FAQ added in 4e5f0a9.

Microsoft's documentation indicates that the Windows 10 SetProcessDpiAwarenessContext() function is recommended instead of SetProcessDpiAwareness() in situations where the DPI awareness cannot be set in the application manifest. I don't understand how to use that function though, so this will do.

@LexiconCode Regarding the issues you mentioned in #289, let me know if this works properly. I think it should be fine.

wolfmanstout commented 4 years ago

Thanks! I also saw that SetProcessDpiAwarenessContext() it is recommended but wasn't able to get that to work (the constants to pass in are defined as macros in a header file in an opaque way). This looks good to me.

drmfinlay commented 4 years ago

Yes, I saw the same header file. Odd way of doing things.

I'll merge this now. Thanks for figuring out how to do this :+1: