Activate Tabtip, modify sample C#

Activate Tabtip, modify sample C#

Postby dutch » Fri Sep 11, 2020 1:26 pm

Dear All,

I found the C# that can activate Tabtip.exe anytime, even ::bGotFocus of GET, not only ACTIVATE clause.
Can we modify to xHarbour?

Thanks in advance,
Code: Select all  Expand view
using System;
using System.Diagnostics;
using Microsoft.Win32;

namespace CSharpTesting
{
    class Program
    {
        /// <summary>
        /// The different layout types on the virtual keyboard.
        /// </summary>
        public enum KeyboardLayoutMode
        {
            Default,
            ThumbLayout,
            Handwriting
        }

        /// <summary>
        /// The registry key which holds the keyboard settings.
        /// </summary>
        private static readonly RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\TabletTip\\1.7");

        static void Main(string[] args)
        {
            SetKeyboardDockedMode(true);
            SetKeyboardLayoutMode(KeyboardLayoutMode.ThumbLayout);
            ShowKeyboard(true);
        }

        /// <summary>
        /// Shows the onscreen keyboard.
        /// </summary>
        /// <param name="killExistingProcess">If true, kill any existing TabTip.exe process.</param>
        public static void ShowKeyboard(bool killExistingProcess)
        {
            if (killExistingProcess)
            {
                // If the user presses the close button on the keyboard then TabTip.exe will still run in the background. If we have made registry
                // changes to the keyboard settings, they don't take effect until the process is started again so killing this ensures the keyboard
                // will open with our new settings.
                foreach (var process in Process.GetProcessesByName("TabTip"))
                {
                    process.Kill();
                }
            }

            string onScreenKeyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
            Process.Start(onScreenKeyboardPath);
        }

        /// <summary>
        /// Sets if the keyboard is in docked or floating mode.
        /// </summary>
        /// <param name="isDocked">If true set to docked, if false set to floating.</param>
        private static void SetKeyboardDockedMode(bool isDocked)
        {
            registryKey.SetValue("EdgeTargetDockedState", Convert.ToInt32(isDocked), RegistryValueKind.DWord);
        }

        /// <summary>
        /// Changes the layout mode of the keyboard.
        /// </summary>
        /// <param name="mode">The layout mode to use.</param>
        private static void SetKeyboardLayoutMode(KeyboardLayoutMode mode)
        {
            switch (mode)
            {
                case KeyboardLayoutMode.Handwriting:
                    registryKey.SetValue("KeyboardLayoutPreference", 0, RegistryValueKind.DWord);
                    registryKey.SetValue("LastUsedModalityWasHandwriting", 1, RegistryValueKind.DWord);
                    break;
                case KeyboardLayoutMode.ThumbLayout:
                    registryKey.SetValue("KeyboardLayoutPreference", 1, RegistryValueKind.DWord);
                    registryKey.SetValue("LastUsedModalityWasHandwriting", 0, RegistryValueKind.DWord);
                    // 0 = small, 1 = medium, 2 = large
                    registryKey.SetValue("ThumbKeyboardSizePreference", 2, RegistryValueKind.DWord);
                    break;
                default:
                    registryKey.SetValue("KeyboardLayoutPreference", 0, RegistryValueKind.DWord);
                    registryKey.SetValue("LastUsedModalityWasHandwriting", 0, RegistryValueKind.DWord);
                    break;
            }
        }
    }
}
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Activate Tabtip, modify sample C#

Postby cnavarro » Fri Sep 11, 2020 3:05 pm

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Activate Tabtip, modify sample C#

Postby dutch » Sat Sep 12, 2020 11:14 am

Dear cnavarro,

I've read this thread already and used it but if the user close the keyboard (tabtip). It cannot activate again even oGet:OnGotFocus. This is the problem.

Thank you in advance,
cnavarro wrote:Dear Dutch
Not enough with this?

viewtopic.php?f=3&t=37570&p=224642&hilit=tabtip#p224617
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Activate Tabtip, modify sample C#

Postby cnavarro » Sat Sep 12, 2020 1:41 pm

Ok, I understand and I will look at it then
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Activate Tabtip, modify sample C#

Postby dutch » Sat Sep 12, 2020 4:07 pm

Thank you so much,
cnavarro wrote:Ok, I understand and I will look at it then
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests