C# 解决模拟键盘事件SendKeys.SendWait()特殊字符转义

一、背景

需要模拟键盘事件输出获取到的第三方的字符串,但是第三方的字符串存在特殊字符,比如+号,用常规方法输出的时候,对特殊字符会进行转义。

二、解决办法

1、使用第三方库InputSimulator

  simulator.Keyboard.TextEntry(字符串内容);

虽然结果不会转义,但是部署到某些电脑上的时候,会报错:
Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.
是用户界面特权隔离,具体原因我也没弄懂,可以看下面这个解释

https://blog.youkuaiyun.com/panjunnn/article/details/11

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值