Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've created a autohotscript to quickly dump selected text into my jot file on the Desktop and I think I'm facing a timing error.

The script works like thus:

  1. Select text when reading a text file, browsing internet, reading PDF, etc.
  2. Hit Ctrl + J
  3. Contents of selected text is dumped into my jot file.

When I press Ctrl + J very quickly, it sometimes doesn't come up in my jot file and sometimes when I keep pressing Ctrl + J for a long time, many instances of the text appear.

Could somebody please point out what's wrong with this script and how I can improve it.

^j::

Clipboard := "" ; clear

Send, ^c ; simulate Ctrl+C (=selection in clipboard)

selection = %Clipboard% ; save the content of the clipboard

FileAppend, `n%selection%`n,C:\Users\jagrati\Desktop\jots.txt

return
share|improve this question
add comment

1 Answer

A few things to try:

  1. Change Send to SendInput. This is a faster input method.
  2. Add ClipWait, 2 under the ^c line. This will wait for new clipboard text (but won't wait for it longer than 2 seconds).
  3. Add Sleep 50 between commands. It's not the best solution, but it may help if the first two things don't.
share|improve this answer
2  
2) seems the most likely solution to me. Sometimes being too fast IS a bad thing. –  Phoshi Jul 4 '10 at 19:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.