WPF与虚拟键盘的那些事

缘起 近期项目使用到相关技术,故整理文章一篇。 获取可用输入设备 软件的本质无非是输入和输出,那么WPF如何获取电脑是否有可用输入设备呢?查询了Google,在StackOverflow上找到一个提问,原帖地址,代码如下: KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities(); return keyboardCapabilities.KeyboardPresent != 0 ? true : false; 如果没有可用输入设备,那么就该虚拟键盘上场了。windows里面有两个虚拟键盘的程序,一个是TabTip.exe一个是osk.exe,可以直接调用进程,也可以使用 WPF的第三方组件https://github.com/maximcus/WPFTabTip 详细实现可以参考后面的链接。 平板模式 下面代码将当前系统的运行模式改为平板模式 public static readonly Guid CLSID_ImmersiveShell = new Guid("C2F03A33-21F5-47FA-B4BB-156362A2F239"); [ComImport()] [Guid("4FDA780A-ACD2-41F7-B4F2-EBE674C9BF2A")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITabletModeController { int GetMode(ref int mode); int SetMode(int mode, int modeTrigger); } [ComImport] [Guid("6D5140C1-7436-11CE-8034-00AA006009FA")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IServiceProvider { [return: MarshalAs(UnmanagedType.IUnknown)] object QueryService(ref Guid service, ref Guid riid); } 调用 var pSP = (IServiceProvider)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_ImmersiveShell)); var pTMC = (ITabletModeController)pSP....

Keep运动接口

基础接口 授权 curl --location --request POST 'https://api.gotokeep.com/v1.1/users/login' \ --header 'Content-Type: application/json' \ --data-raw '{"mobile": 18888888888, "password": "aa"}' 返回token内容需要作为后续请求的header传递,返回示例: { "ok": true, "data": { "userId": "011981111e131", "level": 0, "goal": 0, "gender": "M", "token": "xxxxxxxxxxxx", "userRegisterInfo": null }, "errorCode": "0", "now": "2022-04-21T05:02:57Z", "version": "1.0.0", "text": null, "more": {} } 动作库 获取动作分类 curl --location --request GET 'https://api.gotokeep.com/training/v2/trainingpoints/exerciselib' \ --header 'Authorization: Bearer xxxxxxxxx' 返回 { "ok": true, "data": [ { "name": "胸部", "_id": "54826e417fb786000069ad82", "url": "http://static1....

为Kratos prtobuf文件添加多种编译输出

Csharp 安装Grpc.tools https://www.nuget.org/packages/Grpc.Tools/ 下载解压 nupkg文件(改扩展名为zip),也可以使用附件的7z包 解压 找到tools中对应系统架构的软件,设置下环境变量,让系统可以找到就行。 Linux 需要创建一个符号链接 ln -s `which grpc_csharp_plugin` /usr/bin/protoc-gen-grpc-csharp 修改Kratos项目的Make文件 在api这个make任务中添加下面内容 --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ 完整内容为 .PHONY: api # generate api proto api: protoc --proto_path=./api \ --proto_path=./third_party \ --go_out=paths=source_relative:./api \ --go-http_out=paths=source_relative:./api \ --go-grpc_out=paths=source_relative:./api \ --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ --openapi_out==paths=source_relative:. \ 参考 https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md 📎tools.7z Python 安装必要包 pip install grpclib protobuf 查询路径 which protoc-gen-grpclib_python 或者 which protoc-gen-python_grpc我这里返回信息如下: ➜ czyt which protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpclib_python 如法炮制,创建软链接 ln -s /usr/sbin/protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpc_python 修改Makefile 添加下面的内容,再执行make api生成api即可。 --python_out=....

个人Golang环境安装快速设置

下载 官方下载 https://go.dev/dl/ Google 香港镜像 Golang Downloads Mirrors 更多请参考 Thanks Mirror 环境设置 设置proxy go env -w GOPROXY=https://goproxy.io,https://goproxy.cn,direct 安装相关工具 进程工具 goreman go install github.com/mattn/goreman@latest 框架Cli kratos go install github.com/go-kratos/kratos/cmd/kratos/v2@latest wire go install github.com/google/wire/cmd/wire@latest ent go install entgo.io/ent/cmd/ent@latest entimport go install ariga.io/entimport/cmd/entimport@latest entproto go install entgo.io/contrib/entproto/cmd/entproto@latest 代码Lint golangci-lint go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest golines go install github.com/segmentio/golines@latest Go into the Goland settings and click “Tools” -> “File Watchers” then click the plus to create a new file watcher Set the following properties and confirm by clicking OK: Name: golines File type: Go files Scope: Project Files Program: golines Arguments: $FilePath$ -w Output paths to refresh: $FilePath$ gofumpt go install mvdan....

Rasp3b 安装MongoDB

安装 机器安装的是Manjaro,所以本文介绍的是Manjaro的树莓派3安装方式 ➜ ~ screenfetch czyt@** OS: Manjaro-ARM 22.01 Kernel: aarch64 Linux 5.15.24-1-MANJARO-ARM-RPI ##### Uptime: 21d 21h 58m ####### Packages: Unknown ##O#O## Shell: zsh 5.8.1 ####### Disk: 11G / 118G (9%) ########### CPU: BCM2835 @ 4x 1.2GHz ############# GPU: ############### RAM: 248MiB / 919MiB ################ ################# ##################### ##################### ################# 使用命令 yay -S mongodb44-bin进行安装,安装完毕后 启用服务 systemctl enable mongodb 检查服务状态 systemctl status mongodb ● mongodb.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-03-23 13:11:08 CST; 11s ago Docs: https://docs....

WPF Prism 8如何注册Logging

Nuget包 基础包 Microsoft Logging Abstractions Microsoft Extensions DependencyInjection 可选日志包 可以按实际需求进行选择,如NLog等,我们这里采用的是 Serilog 这个Nuget包Serilog Extensions Logging 根据日志输出的目标不同,可以选择不同的扩展方法包 目标 包名 说明 文件 Serilog.Sinks.File WiteTo可以使用File方法详细说明 命令行 Serilog.Sinks.Console 调试输出 Serilog.Sinks.Debug WiteTo可以使用Debug方法 其他扩展,请搜索 点击 日志容器注册 我们使用的是 DryIoc 进行注册,需要安装Nuget包 DryIoc.Microsoft.DependencyInjection 具体代码如下: protected override IContainerExtension CreateContainerExtension() { var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); return new DryIocContainerExtension(new Container(CreateContainerRules()) .WithDependencyInjectionAdapter(serviceCollection)); } 如果是Unity 则需要安装包 Unity.Microsoft.DependencyInjection 具体代码如下: protected override IContainerExtension CreateContainerExtension() { var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(loggingBuilder => loggingBuilder....

grpc-golang windows环境搭建说明

下载protoc,打开链接 下载后将对应的文件解压到gopath的bin目录。 下载protoc的golang插件。下载地址 链接 下载后放在protoc的同级目录(需要改扩展名为exe) 测试,定义一个Proto syntax = "proto3"; option go_package = ".;hello"; package main; message String { string value = 1; } 然后执行命令 protoc hello.proto --go_out=. ,大功告成,生成的文件内容如下: // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.24.0-devel // protoc v3.12.3 // source: hello.proto package hello import ( proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date....

Rust安装及配置

下载rustup 从此处下载,如果你需要安装vs的cpp生成工具,可以在这个页面进行下载。 设置rustup镜像 字节提供的镜像 https://rsproxy.cn export RUSTUP_DIST_SERVER="https://rsproxy.cn" export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" 设置两个环境变量即可。windows可以使用下面的命令进行设置: setx RUSTUP_DIST_SERVER "https://rsproxy.cn" setx RUSTUP_UPDATE_ROOT "https://rsproxy.cn/rustup" 中科大 设置环境变量 RUSTUP_DIST_SERVER (用于更新 toolchain) export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static 以及 RUSTUP_UPDATE_ROOT (用于更新 rustup) export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup 华中科技大学 **方法一:**在“系统-高级系统设置-环境变量” 中增加环境变量。 变量名为 RUSTUP_DIST_SERVER,值为https://mirrors.hust.edu.cn/rustup。 变量名为 RUSTUP_UPDATE_ROOT,值为https://mirrors.hust.edu.cn/rustup/rustup。 **方法二(推荐):**直接执行下面的Powershell脚本: [System.Environment]::SetEnvironmentVariable("RUSTUP_DIST_SERVER", "https://mirrors.hust.edu.cn/rustup", "User") [System.Environment]::SetEnvironmentVariable("RUSTUP_UPDATE_ROOT", "https://mirrors.hust.edu.cn/rustup/rustup", "User") 设置RUSTUP_HOME和CARGO_HOME可以实现自定义安装路径 对于使用buf的开发者,需要添加下面的内容: [registries.buf] index = "sparse+https://buf.build/gen/cargo/" credential-provider = "cargo:token" 然后登陆,token可以从这里获取 cargo login --registry buf "Bearer {token}" 更多内容,请参考https://buf.build/docs/bsr/generated-sdks/cargo crates.io 镜像 编辑 ~/.cargo/config ,这里使用的是中科大的镜像。 cargo版本 1.39 中添加了对 .toml 扩展的支持,并且是首选形式。如果两个文件都存在,Cargo 将使用不带扩展名的文件。...

一个免费的TTS接口

示例: https://dds.dui.ai/runtime/v1/synthesize?voiceId=ppangf_csn&text=您好世界&speed=1&volume=50&audioType=wav 使用步骤 graph LR; 选择声音 --> 输入要转语音文本 --> 拼接URL --> 使用语音 参数说明: text 要转音频的文本内容 (200字以内) speed 语速 volume 声音大小 voiceId 发音类型可以取下面的值: VoiceId 名称 说明 qiumum_0gushi 精品秋木 活泼开朗适合有声读物等场景 kaolam_diantai 精品考拉 电台男声温柔的电台男声 juan1f 小美 客服女声声音甜美热情,客服、营销场景均适用 xmguof 婷婷 营销女声音色亲切大方,适用于电话销售、调研回访等场景 xmamif 小咪 营销女声活力甜美,适用于电话营销、邀约等场景 lunaif_ctn 晓健 标准粤语女声偏正式的标准粤语,适用于新闻播报等场景 hchunf_ctn 何春 自然粤语女声音色偏甜美自然,适用于家居播报等场景 dayaof_csd 大瑶 山东话女声音色偏甜美自然,适用于家居播报等场景 wqingf_csn 文卿 四川话女声音色偏甜美自然,适用于车载导航等场景 ppangf_csn 胖胖 四川话女声音色偏甜美自然,适用于家居播报等场景 yezi1f_csh 叶子 上海话女声音色偏甜美自然,适用于家居播报等场景 madoufp_yubo 麻豆 娱播女声甜美欢快的女声,适合做娱乐新闻的播报 madoufp_wenrou 麻豆 甜美温柔客服、营销、阅读听书的场景均可使用 xjingfp 小静 甜美女声音色甜美知性,可用于娱乐新闻等播报 xjingf_gushi 小静 自然音色甜美知性,可用于娱乐新闻等播报 xjingf 小静 商务知性音色甜美知性,可用于娱乐新闻等播报 zhilingfp 小玲 甜美女神音色亲切、欢快、自然,适合用于各种场景 zhilingfp_huankuai 小玲 欢快自然音色亲切、欢快、自然,适合用于各种场景 zhilingfa 小玲 标准小玲的音色亲切,甜美,自然,适合用于各种场景 zhilingf 传统小玲 甜美性感音色甜美、自然、性感,适合用于各种场景 anonyf 小佚 平和沉稳音色沉稳严肃,适合用于新闻播报等 xbekef 贝壳 可爱女童童真可爱,适合讲幼儿故事 xijunma 精品小军 新闻播报适合新闻播报等场景 xijunm 传统小军 标准正式标准发音,适合新闻播报等场景 geyou 葛爷 淡定风趣模仿葛优音色 gdgm 纲叔 沉稳幽默模仿郭德纲音色 zxcm 星哥 风趣幽默模仿周星驰音色 qianranf 传统然然 天真俏皮成人女声模仿女童音色 hyanif 小妮 温柔亲切适合情感电台播报等场景 gqlanf 标准小兰 邻家女声温柔的邻家女声,适合做客服音色 gqlanfp 精品小兰 温柔甜美温柔的邻家女声,适合做客服音色 qianranfa 标准然然 天真俏皮语速1....

golang webserver with genergic base64 /favicon.ico

package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/favicon.ico", favicon) http.HandleFunc("/", hello) fmt.Printf("listening on http://localhost:8000/\n") http.ListenAndServe("localhost:8000", nil) } func favicon(w http.ResponseWriter, r *http.Request) { fmt.Printf("%s\n", r.RequestURI) w.Header().Set("Content-Type", "image/x-icon") w.Header().Set("Cache-Control", "public, max-age=7776000") fmt.Fprintln(w, "data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=\n") } func hello(w http.ResponseWriter, r *http.Request) { fmt.Printf("%s\n", r.RequestURI) fmt.Fprintln(w, "Hello, World!") }