请问Windows 10 2004还能用吗?

BUG反馈 · 296 次浏览
Krtsg 创建于 2022-03-25 16:50
我之前也纠结这个问题,弄了好几个方案,最后通过模拟两次徽标+空格实现的切换(我一共就四个键盘,每次按两下能实现切换)
 
与CL大佬的讨论:
https://getquicker.net/KC/Kb/Article/921
 
动作日志:
2Win-10.0.19041.0 Quicker-1.29.3.0 动作ID:9e7aeaa6-af7d-498c-b3bb-46e517cfa142 来源动作:e0502821-3241-4da1-03a2-08d96ff337a7 v4
7Log文件路径:C:\Users\Windows\AppData\Local\Temp\quicker_切换中英文状态_044623-009_log.htm 在资源管理器中查看 复制文件
7开始执行动作:切换中英文状态 2022-03-25 16:46:23
10动作初始化
[状态]chshandle0
[状态]TSF微软拼音
[状态]langid2052
[状态]startFalse
130自定义窗口显示窗口
13已禁用,跳过
131获取系统或动作信息
[out]是否为Win10或以上=>isWin10True
[out]运行个数=>actionCount1
142如果判断条件:$={quicker_in_param}=="setting"||{start}
[in]如果【值/表达式】False
16不符合条件,跳过。
163获取窗口信息/查找窗口查找顶层窗口 (单个窗口)
[in]失败后停止【值/表达式】False
[in]目标窗口【值/表达式】findWindow
[in]窗口类名【值/表达式】
[in]窗口名称【值/表达式】keylock
[in]进程名/pid【值/表达式】
[in]仅可见窗口【值/表达式】default
[in]使用正则匹配窗口类名和标题【无输入】False
20步骤(sys:getWindowTitle)执行失败,原因:未找到窗口。
214如果判断条件:$={handle}==0
[in]如果【值/表达式】True
22执行 True 分支, 共 1 步骤
224.0如果/否则判断条件:{isWin10}
[in]如果【变量 isWin10】True
22执行 True 分支, 共 2 步骤
224.0.0自定义窗口显示窗口
[in]失败后停止【值/表达式】True
[in]操作类型【值/表达式】Show
[in]窗口标识【值/表达式】keylock
[in]窗口XAML代码【值/表达式】<qk:FadeOutWindow\r\n
x:Name="win1"\r\n
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r\n
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r\n
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"\r\n
xmlns:local="clr-namespace:QuickerSampleProject"\r\n
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"\r\n
xmlns:qk="https://getquicker.net"\r\n
Title="switchlang"\r\n
Width="800"\r\n
Height="450"\r\n
AllowsTransparency="True"\r\n
WindowStyle="None"\r\n
Background="Transparent"\r\n
Foreground="White"\r\n
SizeToContent="WidthAndHeight"\r\n
Topmost="True"\r\n
WindowStartupLocation="CenterScreen"\r\n
ShowActivated="False"\r\n
ShowInTaskbar="False"\r\n
mc:Ignorable="d"\r\n
>\r\n
\r\n
<Grid DataContext="{Binding ElementName=root}" Margin="0,50,0,50">\r\n
<Border\r\n
Padding="20"\r\n
Background="#60000000"\r\n
CornerRadius="10">\r\n
\r\n
<StackPanel Orientation="Horizontal">\r\n
\r\n
</StackPanel>\r\n
</Border>\r\n
</Grid>\r\n
</qk:FadeOutWindow>\r\n
[in]窗口位置【值/表达式】BottomLeft
[in]数据映射【值/表达式】ch:{TSF}\r\n
id:{langid}
[in]辅助C#代码【值/表达式】using System;\r\n
using System.Collections.Generic;\r\n
using System.Globalization;\r\n
using System.Linq;\r\n
using System.Runtime.InteropServices;\r\n
using System.Security;\r\n
using System.Text;\r\n
using System.Threading.Tasks;\r\n
using System.Windows;\r\n
using System.Windows.Controls;\r\n
using winForms = System.Windows.Forms;\r\n
using System.Windows.Data;\r\n
using System.Windows.Documents;\r\n
using System.Windows.Input;\r\n
using System.Windows.Media;\r\n
using System.Windows.Media.Imaging;\r\n
using System.Windows.Navigation;\r\n
using System.Windows.Shapes;\r\n
using System.Windows.Interop;\r\n
using Quicker.Public;\r\n
\r\n
\r\n
public static System.Windows.Window win1= new System.Windows.Window();\r\n
public static string la=string.Empty;\r\n
public static void OnWindowLoaded(Window win, IDictionary<string, object> dataContext,\r\n
ICustomWindowContext winContext){\r\n
\t\r\n
\twin1=(Window)win.FindName("win1");\r\n
\twin1.SourceInitialized += window1_SourceInitialized;\r\n
\tla=(string)dataContext["ch"];\r\n
\r\n
}\r\n
public static void window1_SourceInitialized(object sender, EventArgs e)\r\n
{\r\n
\tif (TypewrititngHelper.TSFWrapper.GetCurrentLanguage() == 2052)\r\n
\t{\r\n
\t\tTypewrititngHelper.TSFWrapper.ChangeCurrentLanguage((short)1033);\r\n
\t}\r\n
\telse if (TypewrititngHelper.TSFWrapper.GetCurrentLanguage() == 1033)\r\n
\t{\r\n
\t\tTypewrititngHelper.TSFWrapper.ChangeCurrentLanguage((short)2052);\r\n
\t\tTypewrititngHelper.TSFWrapper.ActiveInputMethodWithDesc((short)2052, la);\r\n
\t}\r\n
\r\n
\t//注册快捷键\r\n
\t/*Hotkey.Regist(win1, HotkeyModifiers.MOD_CONTROL, Key.F1, () =>\r\n
\t {\r\n
\t \tif (TypewrititngHelper.TSFWrapper.GetCurrentLanguage() == 2052)\r\n
\t \t{\r\n
\t \t\tTypewrititngHelper.TSFWrapper.ChangeCurrentLanguage((short)1033);\r\n
\t \t}\r\n
\t \telse if (TypewrititngHelper.TSFWrapper.GetCurrentLanguage() == 1033)\r\n
\t \t{\r\n
\t \t\tTypewrititngHelper.TSFWrapper.ChangeCurrentLanguage((short)2052);\r\n
\t \t\tTypewrititngHelper.TSFWrapper.ActiveInputMethodWithDesc((short)2052, la);\r\n
\t \t}\r\n
\t });*/\r\n
}\r\n
\r\n
\r\n
public enum HotkeyModifiers\r\n
{\r\n
\tNone = 0,\r\n
\tMOD_ALT = 0x1,\r\n
\tMOD_CONTROL = 0x2,\r\n
\tMOD_SHIFT = 0x4,\r\n
\tMOD_WIN = 0x8\r\n
}\r\n
\r\n
class Hotkey\r\n
{\r\n
\t#region 系统api\r\n
\t[DllImport("user32.dll")]\r\n
\t[return: MarshalAs(UnmanagedType.Bool)]\r\n
\tstatic extern bool RegisterHotKey(IntPtr hWnd, int id, HotkeyModifiers fsModifiers, uint vk);\r\n
\r\n
\t[DllImport("user32.dll")]\r\n
\tstatic extern bool UnregisterHotKey(IntPtr hWnd, int id);\r\n
\t#endregion\r\n
\r\n
\t/// <summary>\r\n
\t/// 注册快捷键\r\n
\t/// </summary>\r\n
\t/// <param name="window">持有快捷键窗口</param>\r\n
\t/// <param name="fsModifiers">组合键</param>\r\n
\t/// <param name="key">快捷键</param>\r\n
\t/// <param name="callBack">回调函数</param>\r\n
\tpublic static void Regist(Window window, HotkeyModifiers fsModifiers, Key key, HotKeyCallBackHanlder callBack)\r\n
\t{\r\n
\r\n
\t\tvar hwnd = new WindowInteropHelper(window).Handle;\r\n
\t\tvar _hwndSource = HwndSource.FromHwnd(hwnd);\r\n
\t\t_hwndSource.AddHook(WndProc);\r\n
\r\n
\t\tint id = keyid++;\r\n
\r\n
\t\tvar vk = KeyInterop.VirtualKeyFromKey(key);\r\n
\t\tif (!RegisterHotKey(hwnd, id, fsModifiers, (uint)vk))\r\n
\t\t\tthrow new Exception("regist hotkey fail.");\r\n
\t\tkeymap[id] = callBack;\r\n
\t}\r\n
\r\n
\t/// <summary>\r\n
\t/// 快捷键消息处理\r\n
\t/// </summary>\r\n
\tstatic IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)\r\n
\t{\r\n
\t\tif (msg == WM_HOTKEY)\r\n
\t\t{\r\n
\t\t\tint id = wParam.ToInt32();\r\n
\t\t\tHotKeyCallBackHanlder callback;\r\n
\t\t\tcallback = keymap[id];\r\n
\t\t\tif (callback!=null)\r\n
\t\t\t{\r\n
\t\t\t\tcallback();\r\n
\t\t\t}\r\n
\r\n
\t\t}\r\n
\t\treturn IntPtr.Zero;\r\n
\t}\r\n
\r\n
\t/// <summary>\r\n
\t/// 注销快捷键\r\n
\t/// </summary>\r\n
\t/// <param name="hWnd">持有快捷键窗口的句柄</param>\r\n
\t/// <param name="callBack">回调函数</param>\r\n
\tpublic static void UnRegist(IntPtr hWnd, HotKeyCallBackHanlder callBack)\r\n
\t{\r\n
\t\tforeach (KeyValuePair<int, HotKeyCallBackHanlder> var in keymap)\r\n
\t\t{\r\n
\t\t\tif (var.Value == callBack)\r\n
\t\t\t\tUnregisterHotKey(hWnd, var.Key);\r\n
\t\t}\r\n
\t}\r\n
\r\n
\r\n
\tconst int WM_HOTKEY = 0x312;\r\n
\tstatic int keyid = 10;\r\n
\tstatic Dictionary<int, HotKeyCallBackHanlder> keymap = new Dictionary<int, HotKeyCallBackHanlder>();\r\n
\r\n
\tpublic delegate void HotKeyCallBackHanlder();\r\n
\r\n
}\r\n
\r\n
\r\n
public class TypewrititngHelper\r\n
{\r\n
\r\n
\tpublic interface ITSFHelper\r\n
\t{\r\n
\t\tshort[] GetLangIDS();\r\n
\t\tbool ActiveInputMethodWithDesc(short langID, string desc);\r\n
\t\tstring[] GetInputMethodList(short langID);\r\n
\t\tstring GetCurrentInputMethodDesc(short langID);\r\n
\t\tbool DeActiveInputMethod(short langID);\r\n
\t}\r\n
\tpublic class TSFHelper : ITSFHelper\r\n
\t{\r\n
\t\tpublic short[] GetLangIDS()\r\n
\t\t{\r\n
\t\t\treturn TSFWrapper.GetLangIDs();\r\n
\t\t}\r\n
\t\tpublic bool ActiveInputMethodWithDesc(short langID, string desc)\r\n
\t\t{\r\n
\t\t\treturn TSFWrapper.ActiveInputMethodWithDesc(langID, desc);\r\n
\t\t}\r\n
\t\tpublic string[] GetInputMethodList(short langID)\r\n
\t\t{\r\n
\t\t\treturn TSFWrapper.GetInputMethodList(langID);\r\n
\t\t}\r\n
\t\tpublic string GetCurrentInputMethodDesc(short langID)\r\n
\t\t{\r\n
\t\t\treturn TSFWrapper.GetCurrentInputMethodDesc(langID);\r\n
\t\t}\r\n
\t\tpublic bool DeActiveInputMethod(short langID)\r\n
\t\t{\r\n
\t\t\treturn TSFWrapper.DeActiveInputMethod(langID);\r\n
\t\t}\r\n
\t}\r\n
\r\n
\tpublic static class TSFWrapper\r\n
\t{\r\n
\t\tpublic static short[] GetLangIDs()\r\n
\t\t{\r\n
\t\t\tList<short> langIDs = new List<short>();\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\tIntPtr langPtrs;\r\n
\t\t\t\tint fetchCount = 0;\r\n
\t\t\t\tif (profiles.GetLanguageList(out langPtrs, out fetchCount) == 0)\r\n
\t\t\t\t{\r\n
\t\t\t\t\tfor (int i = 0; i < fetchCount; i++)\r\n
\t\t\t\t\t{\r\n
\t\t\t\t\t\tshort id = Marshal.ReadInt16(langPtrs, sizeof(short) * i);\r\n
\t\t\t\t\t\tlangIDs.Add(id);\r\n
\t\t\t\t\t}\r\n
\t\t\t\t}\r\n
\t\t\t\tMarshal.ReleaseComObject(profiles);\r\n
\t\t\t}\r\n
\t\t\treturn langIDs.ToArray();\r\n
\t\t}\r\n
\t\tpublic static bool ActiveInputMethodWithDesc(short langID, string desc)\r\n
\t\t{\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tIEnumTfLanguageProfiles enumerator = null;\r\n
\t\t\t\t\tif (profiles.EnumLanguageProfiles(langID, out enumerator) == 0)\r\n
\t\t\t\t\t{\r\n
\t\t\t\t\t\tif (enumerator != null)\r\n
\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\tTF_LANGUAGEPROFILE[] langProfile = new TF_LANGUAGEPROFILE[1];\r\n
\t\t\t\t\t\t\tint fetchCount = 0;\r\n
\t\t\t\t\t\t\twhile (enumerator.Next(1, langProfile, out fetchCount) == 0)\r\n
\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\ttry\r\n
\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\tIntPtr ptr;\r\n
\t\t\t\t\t\t\t\t\tif (profiles.GetLanguageProfileDescription(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out ptr) == 0)\r\n
\t\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\t\tbool enabled;\r\n
\t\t\t\t\t\t\t\t\t\tif (profiles.IsEnabledLanguageProfile(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out enabled) == 0)\r\n
\t\t\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\t\t\tif (enabled)\r\n
\t\t\t\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\t\t\t\tstring s = Marshal.PtrToStringBSTR(ptr);\r\n
\r\n
\t\t\t\t\t\t\t\t\t\t\t\tif (s.Equals(desc))\r\n
\t\t\t\t\t\t\t\t\t\t\t\t\treturn profiles.ActivateLanguageProfile(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile) == 0;\r\n
\t\t\t\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\t\t\tMarshal.FreeBSTR(ptr);\r\n
\t\t\t\t\t\t\t\t\t\t//Marshal.FreeCoTaskMem(ptr);\r\n
\t\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\tcatch { }\r\n
\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t}\r\n
\t\t\t\t\t}\r\n
\t\t\t\t}\r\n
\t\t\t\tfinally\r\n
\t\t\t\t{\r\n
\t\t\t\t\tMarshal.ReleaseComObject(profiles);\r\n
\t\t\t\t}\r\n
\t\t\t}\r\n
\t\t\treturn false;\r\n
\t\t}\r\n
\t\tpublic static string[] GetInputMethodList(short langID)\r\n
\t\t{\r\n
\t\t\tList<string> imeList = new List<string>();\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tIEnumTfLanguageProfiles enumerator = null;\r\n
\t\t\t\t\tif (profiles.EnumLanguageProfiles(langID, out enumerator) == 0)\r\n
\t\t\t\t\t{\r\n
\t\t\t\t\t\tif (enumerator != null)\r\n
\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\tTF_LANGUAGEPROFILE[] langProfile = new TF_LANGUAGEPROFILE[1];\r\n
\t\t\t\t\t\t\tint fetchCount = 0;\r\n
\t\t\t\t\t\t\twhile (enumerator.Next(1, langProfile, out fetchCount) == 0)\r\n
\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\tIntPtr ptr;\r\n
\t\t\t\t\t\t\t\ttry\r\n
\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\tif (profiles.GetLanguageProfileDescription(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out ptr) == 0)\r\n
\t\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\t\tbool enabled;\r\n
\t\t\t\t\t\t\t\t\t\tif (profiles.IsEnabledLanguageProfile(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out enabled) == 0)\r\n
\t\t\t\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\t\t\t\tif (enabled)\r\n
\t\t\t\t\t\t\t\t\t\t\t\timeList.Add(Marshal.PtrToStringBSTR(ptr));\r\n
\t\t\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\t\t}\r\n
\r\n
\t\t\t\t\t\t\t\t\tMarshal.FreeBSTR(ptr);\r\n
\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t\tcatch { }\r\n
\t\t\t\t\t\t\t\t//in windows 2008, it will crash.\r\n
\t\t\t\t\t\t\t\t//Marshal.FreeCoTaskMem(ptr);\r\n
\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t}\r\n
\t\t\t\t\t}\r\n
\t\t\t\t}\r\n
\t\t\t\tfinally\r\n
\t\t\t\t{\r\n
\t\t\t\t\tMarshal.ReleaseComObject(profiles);\r\n
\t\t\t\t}\r\n
\t\t\t}\r\n
\t\t\treturn imeList.ToArray();\r\n
\t\t}\r\n
\t\tpublic static string GetCurrentInputMethodDesc(short langID)\r\n
\t\t{\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tGuid clsid;\r\n
\t\t\t\t\tGuid profileid;\r\n
\t\t\t\t\tGuid catid = new Guid(TSF_NativeAPI.GUID_TFCAT_TIP_KEYBOARD.ToByteArray());\r\n
\t\t\t\t\tif (profiles.GetDefaultLanguageProfile(langID, ref catid, out clsid, out profileid) == 0)\r\n
\t\t\t\t\t{\r\n
\r\n
\t\t\t\t\t\tif (profiles.GetActiveLanguageProfile(ref clsid, out langID, out profileid) == 0)\r\n
\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\tIntPtr ptr;\r\n
\t\t\t\t\t\t\ttry\r\n
\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\tif (profiles.GetLanguageProfileDescription(ref clsid, langID, ref profileid, out ptr) == 0)\r\n
\t\t\t\t\t\t\t\t{\r\n
\r\n
\t\t\t\t\t\t\t\t\tstring s = Marshal.PtrToStringBSTR(ptr);\r\n
\t\t\t\t\t\t\t\t\tMarshal.FreeBSTR(ptr);\r\n
\t\t\t\t\t\t\t\t\t//in windows 2008 , it will carsh.\r\n
\t\t\t\t\t\t\t\t\t//Marshal.FreeCoTaskMem(ptr);\r\n
\t\t\t\t\t\t\t\t\treturn s;\r\n
\t\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t\tcatch (Exception ex)\r\n
\t\t\t\t\t\t\t{\r\n
\t\t\t\t\t\t\t\tint i = 0;\r\n
\t\t\t\t\t\t\t}\r\n
\t\t\t\t\t\t}\r\n
\t\t\t\t\t}\r\n
\t\t\t\t}\r\n
\t\t\t\tfinally\r\n
\t\t\t\t{\r\n
\t\t\t\t\tMarshal.ReleaseComObject(profiles);\r\n
\t\t\t\t}\r\n
\t\t\t}\r\n
\t\t\treturn string.Empty;\r\n
\t\t}\r\n
\r\n
\t\tpublic static bool DeActiveInputMethod(short langID)\r\n
\t\t{\r\n
\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tGuid clsid = Guid.Empty;\r\n
\t\t\t\t\treturn profiles.ActivateLanguageProfile(ref clsid, langID, ref clsid) == 0;\r\n
\t\t\t\t}\r\n
\t\t\t\tcatch { }\r\n
\t\t\t\tfinally\r\n
\t\t\t\t{\r\n
\t\t\t\t\tMarshal.ReleaseComObject(profiles);\r\n
\t\t\t\t}\r\n
\t\t\t}\r\n
\t\t\treturn false;\r\n
\t\t}\r\n
\t\t/// <summary>\r\n
\t\t/// 更改当前键盘类型\r\n
\t\t/// </summary>\r\n
\t\t/// <param name="langID"></param>\r\n
\t\t/// <returns></returns>\r\n
\t\tpublic static bool ChangeCurrentLanguage(short langID)\r\n
\t\t{\r\n
\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tprofiles.ChangeCurrentLanguage(langID);\r\n
\t\t\t\t}\r\n
\t\t\t\tcatch { }\r\n
\t\t\t}\r\n
\t\t\treturn false;\r\n
\t\t}\r\n
\t\t/// <summary>\r\n
\t\t/// 获取当前键盘类型\r\n
\t\t/// </summary>\r\n
\t\t/// <returns>语言id</returns>\r\n
\t\tpublic static int GetCurrentLanguage()\r\n
\t\t{\r\n
\t\t\tshort langID = 0;\r\n
\t\t\tITfInputProcessorProfiles profiles;\r\n
\t\t\tif (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)\r\n
\t\t\t{\r\n
\t\t\t\ttry\r\n
\t\t\t\t{\r\n
\t\t\t\t\tprofiles.GetCurrentLanguage(out langID);\r\n
\t\t\t\t}\r\n
\t\t\t\tcatch { }\r\n
\t\t\t}\r\n
\t\t\treturn langID;\r\n
\t\t}\r\n
\t}\r\n
\r\n
\t[StructLayout(LayoutKind.Sequential)]\r\n
\tinternal struct TF_LANGUAGEPROFILE\r\n
\t{\r\n
\t\tinternal Guid clsid;\r\n
\t\tinternal short langid;\r\n
\t\tinternal Guid catid;\r\n
\t\t[MarshalAs(UnmanagedType.Bool)]\r\n
\t\tinternal bool fActive;\r\n
\t\tinternal Guid guidProfile;\r\n
\t}\r\n
\t[ComImport, SecurityCritical, SuppressUnmanagedCodeSecurity,\r\n
\t Guid("1F02B6C5-7842-4EE6-8A0B-9A24183A95CA"),\r\n
\t InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\r\n
\tinternal interface ITfInputProcessorProfiles\r\n
\t{\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid Register(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid Unregister(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid AddLanguageProfile(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid RemoveLanguageProfile(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid EnumInputProcessorInfo(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tint GetDefaultLanguageProfile(short langid, ref Guid catid, out Guid clsid, out Guid profile);\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid SetDefaultLanguageProfile();//non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tint ActivateLanguageProfile(ref Guid clsid, short langid, ref Guid guidProfile);\r\n
\t\t[PreserveSig, SecurityCritical]\r\n
\t\tint GetActiveLanguageProfile(ref Guid clsid, out short langid, out Guid profile);\r\n
\t\t[SecurityCritical]\r\n
\t\tint GetLanguageProfileDescription(ref Guid clsid, short langid, ref Guid profile, out IntPtr desc);\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid GetCurrentLanguage(out short langid); //non-implement!! may be is wrong declaration.\r\n
\t\t[PreserveSig, SecurityCritical]\r\n
\t\tint ChangeCurrentLanguage(short langid); //non-implement!! may be is wrong declaration.\r\n
\t\t[PreserveSig, SecurityCritical]\r\n
\t\tint GetLanguageList(out IntPtr langids, out int count);\r\n
\t\t[SecurityCritical]\r\n
\t\tint EnumLanguageProfiles(short langid, out IEnumTfLanguageProfiles enumIPP);\r\n
\t\t[SecurityCritical]\r\n
\t\tint EnableLanguageProfile();\r\n
\t\t[SecurityCritical]\r\n
\t\tint IsEnabledLanguageProfile(ref Guid clsid, short langid, ref Guid profile, out bool enabled);\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid EnableLanguageProfileByDefault(); //non-implement!! may be is wrong declaration.\r\n
\t\t[SecurityCritical]\r\n
\t\tvoid SubstituteKeyboardLayout(); //non-implement!! may be is wrong declaration.\r\n
\t}\r\n
\t[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown),\r\n
\t Guid("3d61bf11-ac5f-42c8-a4cb-931bcc28c744")]\r\n
\tinternal interface IEnumTfLanguageProfiles\r\n
\t{\r\n
\t\tvoid Clone(out IEnumTfLanguageProfiles enumIPP);\r\n
\t\t[PreserveSig]\r\n
\t\tint Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)]\r\n
\t\t TF_LANGUAGEPROFILE[] profiles, out int fetched);\r\n
\t\tvoid Reset();\r\n
\t\tvoid Skip(int count);\r\n
\t}\r\n
\tinternal static class TSF_NativeAPI\r\n
\t{\r\n
\t\tpublic static readonly Guid GUID_TFCAT_TIP_KEYBOARD;\r\n
\t\tstatic TSF_NativeAPI()\r\n
\t\t{\r\n
\t\t\tGUID_TFCAT_TIP_KEYBOARD = new Guid(0x34745c63, 0xb2f0,\r\n
\t\t\t 0x4784, 0x8b, 0x67, 0x5e, 0x12, 200, 0x70, 0x1a, 0x31);\r\n
\t\t}\r\n
\t\t[SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("msctf.dll")]\r\n
\t\tpublic static extern int TF_CreateInputProcessorProfiles(out ITfInputProcessorProfiles profiles);\r\n
\t}\r\n
}
[in]窗口尺寸/位置【值/表达式】
[in]激活模式【值/表达式】AutoActivate
[in]事件【值/表达式】
[in]自动关闭时间(S)【值/表达式】0
[in]失去焦点后关闭窗口【值/表达式】False
24使用缓存的程序集
[out]是否成功=>isSuccessTrue
1634.0.1模拟按键A(录入)LeftCtrl+ [ F1 ]
164已禁用,跳过
1645自定义窗口关闭窗口
[in]失败后停止【值/表达式】True
[in]操作类型【值/表达式】Close
[in]窗口标识【值/表达式】keylock
164找到并关闭了窗口。
[out]是否成功=>isSuccessTrue
164动作结束
Krtsg 最后更新于 2022/3/25

回复内容
暂无回复
回复主贴