You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.7KB

  1. /* ----
  2. * ---- file : lglw_windows_cpp.cpp
  3. * ---- author : bsp
  4. * ---- legal : Distributed under terms of the MIT LICENSE (MIT).
  5. * ----
  6. * ---- Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * ---- of this software and associated documentation files (the "Software"), to deal
  8. * ---- in the Software without restriction, including without limitation the rights
  9. * ---- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * ---- copies of the Software, and to permit persons to whom the Software is
  11. * ---- furnished to do so, subject to the following conditions:
  12. * ----
  13. * ---- The above copyright notice and this permission notice shall be included in
  14. * ---- all copies or substantial portions of the Software.
  15. * ----
  16. * ---- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * ---- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * ---- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * ---- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * ---- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * ---- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * ---- THE SOFTWARE.
  23. * ----
  24. * ---- info : This is part of the "lglw" package.
  25. * ----
  26. * ---- created: 09Aug2018
  27. * ---- changed:
  28. * ----
  29. * ----
  30. */
  31. #include "lglw.h"
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. #include <string.h>
  35. #include <windows.h>
  36. #include <windowsx.h>
  37. #include <initguid.h> // for touch keyboard
  38. #include <Objbase.h> // for touch keyboard
  39. #include <Shobjidl.h> // for IFrameworkInputPane
  40. // ---------------------------------------------------------------------------- lglw_int_touchkeyboard_toggle
  41. // 4ce576fa-83dc-4F88-951c-9d0782b4e376
  42. DEFINE_GUID(CLSID_UIHostNoLaunch,
  43. 0x4CE576FA, 0x83DC, 0x4f88, 0x95, 0x1C, 0x9D, 0x07, 0x82, 0xB4, 0xE3, 0x76);
  44. // 37c994e7_432b_4834_a2f7_dce1f13b834b
  45. DEFINE_GUID(IID_ITipInvocation,
  46. 0x37c994e7, 0x432b, 0x4834, 0xa2, 0xf7, 0xdc, 0xe1, 0xf1, 0x3b, 0x83, 0x4b);
  47. struct ITipInvocation : IUnknown
  48. {
  49. virtual HRESULT STDMETHODCALLTYPE Toggle(HWND wnd) = 0;
  50. };
  51. extern "C" lglw_bool_t lglw_int_touchkeyboard_toggle(void) {
  52. // by "torvin", <https://stackoverflow.com/questions/38774139/show-touch-keyboard-tabtip-exe-in-windows-10-anniversary-edition>
  53. HRESULT hr;
  54. lglw_bool_t r = LGLW_FALSE;
  55. ITipInvocation *tip;
  56. hr = CoInitialize(0);
  57. hr = CoCreateInstance(CLSID_UIHostNoLaunch, 0, CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER, IID_ITipInvocation, (void**)&tip);
  58. if(NULL != tip)
  59. {
  60. tip->Toggle(GetDesktopWindow());
  61. tip->Release();
  62. r = LGLW_TRUE;
  63. }
  64. return r;
  65. }