AHK copy and paste script not copying correctly

I’m trying to create a program that copies a string of text then pastes it, but for some reason it won’t copy and CopyWait 5 always times out

Backspace::
MouseMove, 500, 325
Click down
MouseMove, 1245, 325
Clipboard =
Send, ^c
ClipWait 2
msgbox, %Clipboard%
Click up
Click
sleep, 100
clip1=%Clipboard%
Send, %clip1%

Any ideas on how to fix this and what I’m doing wrong?

Answer

The MouseMove / Click / MouseMove looks like you’re shading the text you want to copy?

Does ^c work normally in the program you are copying from if the mouse button is still held down? (you can check that manually)…because in the script above, the mouse click is not released until after the copy command–I would have expected the Click up statement follow the second MouseMove, before clipboard is cleared, although I don’t think it should really have an impact either way in most programs, it might be something to try.

MouseMove, 500, 325
Click down
MouseMove, 1245, 325
Click up

On a side note, you can also save/restore the clipboard if you don’t want your script to permanently modify it…

lastClipboard=%clipboardAll%
Clipboard = 


; (code that modifies the clipboard goes here)


clipboard=%lastClipboard%