需求:window系统下,点击输入窗口时,需要自动弹出手写输入法。点击除输入窗口外位置时,需要关闭手写输入法。
实现:
一、安装手写输入法插件(我选用的是搜狗输入法)
二、创建一个添加注册表文件:hinput.reg。然后编辑如下内容
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Handinput]
@="URL:Handinput Protocol Handler"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\Handinput\DefaultIcon]
@="C:\\Program Files (x86)\\SogouInput\\Components\\HandInput\\1.1.0.328\\handinput.exe"
[HKEY_CLASSES_ROOT\Handinput\shell]
[HKEY_CLASSES_ROOT\Handinput\shell\open]
[HKEY_CLASSES_ROOT\Handinput\shell\open\command]
@="\"C:\\Program Files (x86)\\SogouInput\\Components\\HandInput\\1.1.0.328\\handinput.exe\" \"%1\""
该内容主要功能就是把插件写到注册表。
保存并退出文件,然后运行该文件。
三、调用方式(我用的是js调用方式)
function sogo() //打开手写输入法
{
window.location.href="Handinput://test"
}
function close() //关闭手写输入法
{
let cmd=new ActiveXObject("WScript.Shell");
cmd.run("taskkill /f /t /im handinput.exe",0);
}
<body>
<input type="text" id="msg" οnfοcus="sogo()" />
<input type="button" value="Send" οnclick="close()" />
</body>