在Powershell中以编程方式转储路径时,重复字符被跳过

Repeat character is getting skipped while dumping path programmatically in Powershell

本文关键字:字符 路径 Powershell 编程 转储 方式      更新时间:2023-10-16

我正在使用SendMessage API将脚本文件路径中的字符逐个转储到Powershell控制台上。

在第一次执行程序时,powershell 会从产生问题的路径中跳过重复的字符。

例如 "C:\myFolder\abbc\test.ps1">

当我将字符转储到 powershell 窗口时,从上面的路径,它会从"abbc"跳过 1 b,因此在控制台上转储的最终路径是"C:\myFolder\abc\test.ps1"。

这只发生在应用程序的第一次执行中,在随后的执行中它工作正常,也接受重复字符。

SendMessage

不是正确的方法。您应该使用SendInput.另请参阅如何使用 sendinput 函数C++了解更多信息。