🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #262825

Kill&ReStart the "touch keyboard" before bringing it "up" ( on screen ).

#262825
From: Jeff-Relf.Me
Date: Sat, 28 Jul 2018 19:31
82 lines
4858 bytes
https://stackoverflow.com/questions/38774139/show-touch-keyboard-tabtip-exe-in-windows-10-anniversary-edition#51376030

The keyboard toggle ( ITipInvocation.Toggle() ) 
does _ N O T _ always bring up the "touch keyboard"
( Win10 DesktopMode Ver 1803 ).

The solution: use IFrameworkInputPane.Location() to see if the keyboard
is "down" ( off screen ) and, if it is, kill the keyboard processes
and relaunch them before bringing it "up" ( on screen ) again.

This solution has been tested by me, over several days,
and confirmed to work every time, no ( R A N D O M ) stalling.

To toggle the keyboard on and off ( from X.CPP in Jeff-Relf.Me/X.ZIP ):
    
if ( WM == WM_HOTKEY && C == 'K' ) {
    
  //  A mouse button takes me here.  Jeff-Relf.Me/g600.PNG
    
  unsigned __int64  u[2] ;  IFrameworkInputPane  *Loc ;
  Loc = 0, CoCreateInstance( CLSID_FrameworkInputPane, 0, 
    CLSCTX_INPROC_SERVER, IID_IFrameworkInputPane, (void**) & Loc );

  //  "__int64 u[2]" is the same size as "RECT";
  //  both are four 32 bit ints: top, left, bottom, right.
    
  if ( !Loc || ( Loc->Location( (RECT*)&u ), Loc->Release(), !*u && !u[1] ) )
    
    //  The keyboard is "down" ( off screen ),
    //  Kill&ReStart it before bringing it "up" ( on screen ). 
    
    KillProc = 1, Running( L"TabTIP.EXE" ), KillProc = 1, Running( 
    L"WindowsInternal.ComposableShell.Experiences.TextInput.InputApp.EXE" ),
    Launch( L"%CommonProgramFiles%/microsoft shared/ink/TabTIP.EXE" ),
    Sleep(99);
    
  static const GUID CLSID_UIHostNoLaunch = {  0x4CE576FA, 0x83DC, 0x4f88,
    0x95, 0x1C, 0x9D, 0x07, 0x82, 0xB4, 0xE3, 0x76 };
  static const GUID IID_ITipInvocation = {  0x37c994e7, 0x432b, 0x4834,
    0xa2, 0xf7, 0xdc, 0xe1, 0xf1, 0x3b, 0x83, 0x4b };
  static struct ITipInvocation : IUnknown {  virtual HRESULT 
    STDMETHODCALLTYPE  Toggle( HWND wnd ) = 0 ;  }  * Tog ;
    
  Tog = 0, CoCreateInstance( CLSID_UIHostNoLaunch, 0, CLSCTX_INPROC_HANDLER
    | CLSCTX_LOCAL_SERVER, IID_ITipInvocation, (void**) & Tog );
    
  //  Toggle the keyboard On|Off: 
    
  Tog ? Tog->Toggle( GetDesktopWindow() ), Tog->Release() : 0 ;    }
- - - - - - - - - - - - -
//  Poorly documented, "NTDDI_WIN10" is _vital_:
#define  NTDDI_VERSION  NTDDI_WIN10
     
//  To get the process list, and kill stuff: 
#include <tlhelp32.H>
     
//  To know if the keyboard is up or not: 
#include <ShObjIdl.H>
    
    
      int  KillProc ;
int Running( wchar * EXE ) {  int  Found ;  HANDLE  PIDs, aProc ;
  PROCESSENTRY32  aPID = { sizeof aPID };
  PIDs = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  Process32First( PIDs, &aPID );
  while ( Found = !strCmpI( aPID.szExeFile, EXE ),
    KillProc && Found && ( 
      aProc = OpenProcess( PROCESS_TERMINATE, 0, aPID.th32ProcessID ),
      aProc ? TerminateProcess( aProc, 9 ), CloseHandle( aProc ) : 0 ),
    !Found && Process32Next( PIDs, &aPID ) );
      
  KillProc = 0, CloseHandle( PIDs );  return  Found ;   }
    
    
Launch( wchar * Cmd ) {  wchar _Cmd[333];  static PROCESS_INFORMATION Stat ;
  static STARTUPINFO SU = { sizeof SU };
  SetEnvironmentVariable( L"__compat_layer", L"RunAsInvoker" );
  ExpandEnvironmentStrings( Cmd, _Cmd, 333 ), Cmd = _Cmd ;
  if ( CreateProcess( 0, Cmd, 0,0,1,0,0,0, &SU , &Stat ) )
    CloseHandle( Stat.hProcess ), CloseHandle( Stat.hThread );  }
    
//  CoInitialize(0);
Technical Details
Message-ID: <Jeff-Relf.Me@Jul.28--0.31pm.Seattle.2018>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.c++.(381507).mbox.7z!not-for-mail
References: <Jeff-Relf.Me@Jul.15--10.09pm.Seattle.2018> <Jeff-Relf.Me@Jul.16--6.12am.Seattle.2018> <Jeff-Relf.Me@Jul.16--9.02am.Seattle.2018> <Jeff-Relf.Me@Jul.17--1.14am.Seattle.2018> <Jeff-Relf.Me@Jul.17--8.40pm.Seattle.2018> <Jeff-Relf.Me@Jul.21--2.32am.Seattle.2018> <Jeff-Relf.Me@Jul.22--10.17am.Seattle.2018> <Jeff-Relf.Me@Jul.23--3.12am.Seattle.2018> <Jeff-Relf.Me@Jul.23--4.34pm.Seattle.2018> <Jeff-Relf.Me@Jul.25--5.48am.Seattle.2018>

Show Full Headers
Complete Article Headers
Message-ID: <Jeff-Relf.Me@Jul.28--0.31pm.Seattle.2018>
Subject: Kill&ReStart the "touch keyboard" before bringing it "up" ( on screen ).
Date: Sat, 28 Jul 2018 19:31:05 +0000
From: Jeff-Relf.Me @.
References: <Jeff-Relf.Me@Jul.15--10.09pm.Seattle.2018> <Jeff-Relf.Me@Jul.16--6.12am.Seattle.2018> <Jeff-Relf.Me@Jul.16--9.02am.Seattle.2018> <Jeff-Relf.Me@Jul.17--1.14am.Seattle.2018> <Jeff-Relf.Me@Jul.17--8.40pm.Seattle.2018> <Jeff-Relf.Me@Jul.21--2.32am.Seattle.2018> <Jeff-Relf.Me@Jul.22--10.17am.Seattle.2018> <Jeff-Relf.Me@Jul.23--3.12am.Seattle.2018> <Jeff-Relf.Me@Jul.23--4.34pm.Seattle.2018> <Jeff-Relf.Me@Jul.25--5.48am.Seattle.2018>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.c++.(381507).mbox.7z!not-for-mail
Content-Type: Text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Newsgroups: comp.os.linux.advocacy,sci.physics,alt.comp.os.windows-10,news.software.readers,comp.lang.c++,alt.checkmate
User-Agent: Jeff-Relf.Me/X.HTM
Lines: 82
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sat, 28 Jul 2018 19:31:05 UTC
Organization: usenet-news.net
X-Received-Bytes: 4665
X-Received-Body-CRC: 2636002874