using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tainikey
{
    public static class TextHelper
    {
        public static char? GetLastChar()
        {
            try
            {
                // Chọn ký tự bên trái
                SendKeys.SendWait("+{LEFT}");
                SendKeys.Flush();

                Clipboard.Clear();
                SendKeys.SendWait("^c");
                SendKeys.Flush();

                string text = Clipboard.GetText();

                // Bỏ chọn
                SendKeys.SendWait("{RIGHT}");
                SendKeys.Flush();

                if (!string.IsNullOrEmpty(text))
                    return text[0];
            }
            catch
            {
                return null;
            }

            return null;
        }
    }
}
