为什么使用 {ctrl down}c{ctrl up} 复制比 ^c 更安全?

Why is copying with {ctrl down}c{ctrl up} more secure than ^c?

AutoHotkey Beginner Tutorial includes the following sample script 演示热键。

^b::
   send, {ctrl down}c{ctrl up}             ; Copies the selected text. ^c could be used as well, but this method is more secure.
   SendInput, [b]{ctrl down}v{ctrl up}[/b]
Return

代码注释表明 {ctrl down}c{ctrl up} 是一种比 ^c 更安全的文本复制方式。但是,该教程从未详细说明 为什么 后一种方法不太安全。

为什么使用 {ctrl down}c{ctrl up} 复制文本被认为比使用 ^c 更安全?

"Secure" 在他们的意思是,命令更有可能在命令发送到的大多数应用程序中成功。

首先,检查发送类型(SendInput、SendDirect、SendPlay 等)及其各种特性。

当您使用任何类型的发送方法时,它实际上并没有按下您的键盘键 - 它正在向活动的 window 发送控制消息(因此有时需要不同的发送方法)。

接下来,一切都与时间有关,假设消息已通过。

如果你要使用{ctrl down}your-stuff{ctrl up}你可以单独控制每个的时间,例如:

Send {ctrl down}
Sleep 200
Send c
Sleep 200
Send {ctrl up}

如果系统不接受您的 ^c 类型的命令,这有时是必要的 - 这几乎总是由于发送消息的时间或缓冲问题。在 windowed 应用程序中工作时,我大部分时间都摆脱了 ^c 类型的消息。但是,如果您在 DirectX 应用程序(如游戏)中工作,明确按下和按下键事件的时间是至关重要的。