一、背景
需要模拟键盘事件输出获取到的第三方的字符串,但是第三方的字符串存在特殊字符,比如+号,用常规方法输出的时候,对特殊字符会进行转义。
二、解决办法
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.
是用户界面特权隔离,具体原因我也没弄懂,可以看下面这个解释