I would have a look at your
KeyHistory to see what is happening with your keys.
Code: Select all
#Requires AutoHotkey v2.0
^p Up:: {
KeyWait 'Ctrl'
SendEvent '{Text}' A_Clipboard
}
Yes, unexpected things can sometimes happen when you hold
Ctrl or other modifiers while text is sent. It is not necessarily a
bug but might relate to the timing of sending a long string of text, with programmed delays, while you are pressing other keys at the same time. Again, KeyHistory will show. Software conflicts may also arise with other programs.
The script above has several differences.
- Simpler
- Waits for both keys to be released: often fixes the problem
- Uses text mode to avoid interpreting special characters that may be on the clipboard
- Uses SendEvent, which has a similar effect (though not entirely identical) to sleeping for 10 ms after each character or key
- Uses no additional variables because such variables are not needed
A general rule of thumb about text mode is that if you are using Send to send variable contents without knowing whether they contain special characters (e.g., "#", "!", "+", "^"), and you do not want the special characters to be interpreted, use text mode. There are some additional situations where text mode is also useful. The documentation contains additional details.
If SetKeyDelay is not used, the default delay is 10 for the traditional SendEvent mode and -1 for SendPlay mode. The default press duration is -1 for both modes. SetKeyDelay is not obeyed by SendInput; there is no delay between keystrokes in that mode. This same is true for Send when SendMode Input is in effect. A short delay (sleep) is done automatically after every keystroke sent by Send or ControlSend. This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of keystrokes.
During the delay (sleep), the current thread is made uninterruptible.