🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #262801

Another fail, another post...

#262801
From: Jeff-Relf.Me
Date: Sun, 22 Jul 2018 17:17
104 lines
5921 bytes
<PRE Style='Font-Family: OCR A, monospace !important;'>
stackoverflow.com/questions/50623154/c-sharp-wpf-windows-10-1803-touchkeyboard-unreliable-issue-prism-clickonce
More like this:

    //  - Ensure InputApp and TabTip are running
    //    ( may have to ReStart Explorer ).
    //  - If the previous keyboard toggle Failed, kill InputApp, try again.
    //  - Toggle the keyboard.

    if ( WM == WM_HOTKEY && C == 'K' ) {  //  A mouse button takes me here.
      int  Fail, Up ;  static int  PrevUp = -1 ;
      u64  u[2] ;  IFrameworkInputPane  *kb ;
  
      //  - Ensure InputApp and TabTip are running
      //    ( may have to ReStart Explorer ):
      ReTry:    !InputApp ? eXplorer, InputApp : 0,  TabTip ;

      Fail = 1, Up = -1, kb = 0, CoCreateInstance( CLSID_FrameworkInputPane, 0,
         CLSCTX_INPROC_SERVER, IID_IFrameworkInputPane, (void**) &amp;kb);
  
      kb ? kb->Location( (RECT*)&amp;u ), Up = !!( *u + u[1] ),
           Fail = Up == PrevUp, PrevUp = Up, kb->Release() : 0 ;
  
      //  - If the previous keyboard toggle Failed, kill InputApp, try again:

      if ( Fail ) {

        PrevUp = -1, KillProc = 1, Running( L"WindowsInternal.ComposableShell"
        L".Experiences.TextInput.InputApp.EXE" );   goto ReTry ;   }

      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 };
      struct ITipInvocation : IUnknown {  virtual HRESULT STDMETHODCALLTYPE
         Toggle( HWND wnd ) = 0;  }  * KB = 0 ;
      CoCreateInstance( CLSID_UIHostNoLaunch, 0, CLSCTX_INPROC_HANDLER |
         CLSCTX_LOCAL_SERVER, IID_ITipInvocation, (void**) & KB );
  
      //  Toggle the keyboard ( Firefox and Chrome require this ):
      KB ? KB->Toggle( GetDesktopWindow() ), KB->Release() : 0 ;   }
        .....
    //  Poorly documented, "NTDDI_WIN10" is _vital_:
    #define  NTDDI_VERSION  NTDDI_WIN10
  
    //  To get the process list, and kill stuff: 
    #include &lt;tlhelp32.H>
  
    //  To know if the keyboard is up or not: 
    #include &lt;ShObjIdl.H>
      
    #define  Eqi  !strCmpI
    #define  FromEnd  wcsrchr

    #define  eXplorer  ( Verify = 1, Launch(  \
       L"%ComSpec% /C \"taskkill /f /im explorer && start explorer\""  ) )

    #define  InputApp  ( Verify = 1, Launch(           \
       L"%WinDir%/SystemApps/InputApp_cw5n1h2txyewy/"  \
       L"WindowsInternal.ComposableShell.Experiences"  \
       L".TextInput.InputApp.EXE"  ) )

    #define  TabTip  ( Verify = 1, Launch(  \
       L"%CommonProgramW6432%/microsoft shared/ink/TabTip.EXE"  ) )

    typedef wchar  *LnP ;
    typedef unsigned __int64  u64 ;
  
          int  KillProc ;
    int Running( LnP EXE ) {  int  Found ;
  
      HANDLE  PIDs, aProc ;  PROCESSENTRY32  aPID = { sizeof aPID };
      PIDs = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
      Process32First( PIDs, &amp;aPID );
      while ( Found = Eqi( aPID.szExeFile, EXE ),
        KillProc && Found &&
        ( aProc = OpenProcess( PROCESS_TERMINATE, 0, aPID.th32ProcessID ) )
        ? TerminateProcess( aProc, 9 ), CloseHandle( aProc ) : 0,
        !Found && Process32Next( PIDs, &amp;aPID ) );
  
      KillProc = 0, CloseHandle( PIDs );  return  Found ;    }
  
          int  Verify ;
    int Launch( LnP Cmd ) {  
      int  V = Verify ;  Verify = 0 ;  LnP  EXE ;  wchar  _Cmd[333];
      static PROCESS_INFORMATION Stat ;
      static STARTUPINFO SU = { sizeof SU };
  
      SetEnvironmentVariable( L"__compat_layer", L"RunAsInvoker" );
      ExpandEnvironmentStrings( Cmd, _Cmd, 333 ), Cmd = _Cmd ;
      P = FromEnd( Cmd, '/' ), EXE = V && P ? ++P : 0 ;
      ReRun:    if ( EXE && Running( EXE ) ) return  1 ;
      if ( V == -1 ) {
        Sh( L"īŧœ%sīŧž dies after launching.", Cmd );  return  0 ;  }

      if ( !CreateProcess( 0, Cmd, 0,0,1,0,0,0, &amp;SU , &amp;Stat ) ) {
        int  Err = GetLastError();  wchar  Msg[333];  *Msg = 0 ; 
        FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, Err, 0, Msg, 333, 0 );
        Sh( L"Error: %d, %s\n\n  īŧœ%sīŧž wasn't launched", Err, Msg, Cmd );
        return  0 ;  }

      CloseHandle( Stat.hProcess ), CloseHandle( Stat.hThread );

      if ( !V ) return  1 ;  V = -1, Sleep(999);  goto ReRun ;   }
Technical Details
Message-ID: <Jeff-Relf.Me@Jul.22--10.17am.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: <fq0renFglc7U1@mid.individual.net> <phfok1$fmb$3@dont-email.me> <a960d541-aed5-43b0-9fd9-7e6ec469940a@googlegroups.com> <Jeff-Relf.Me@Jul.10--2.24am.Seattle.2018> <Jeff-Relf.Me@Jul.10--1.52pm.Seattle.2018> <0eet1f-5ld.ln1@news.neodome.net> <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>

Show Full Headers
Complete Article Headers
Message-ID: <Jeff-Relf.Me@Jul.22--10.17am.Seattle.2018>
Subject: Another fail, another post...
Date: Sun, 22 Jul 2018 17:17:59 +0000
From: Jeff-Relf.Me @.
References: <fq0renFglc7U1@mid.individual.net> <phfok1$fmb$3@dont-email.me> <a960d541-aed5-43b0-9fd9-7e6ec469940a@googlegroups.com> <Jeff-Relf.Me@Jul.10--2.24am.Seattle.2018> <Jeff-Relf.Me@Jul.10--1.52pm.Seattle.2018> <0eet1f-5ld.ln1@news.neodome.net> <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>
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/HTML; 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: 104
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sun, 22 Jul 2018 17:17:58 UTC
Organization: usenet-news.net
X-Received-Bytes: 5734
X-Received-Body-CRC: 28898241