I don't know if this will be possible at all but here is an example for a better illustration.

Let's say we got a little list of words:





Let's say we can select house by using ctrl + a. Now if we want to select next word, we press tab button, and then again ctrl + a..

I want that every word is saved somewhere, so when I press button f1, then house will be pasted. When I press f2, computer will be pasted, etc.

When I reached a specific amount of words, I want that we empty the "cache" or whatever it might be called :p

Is that possible at all with autohotkey? I got some basic knowledge but this is a bit more adventurous imo.

; Create an object (array) to save the selected word (value) 
; each time you press your key (combination): 

MyArray := []
Index := 0
MaxIndex = 12       ; specific amount of words

; select next word and press your key (e.g. esc) to save the selected word in the array:

ClipSaved := ClipboardAll  ; save the entire clipboard to the variable ClipSaved
clipboard := "" ; empty clipboard
Send, ^c        ; copy the selected word
ClipWait 1      ; wait for the clipboard to contain data
If !ErrorLevel  ; If NOT ErrorLevel clipwait found data on the clipboard
    Index++     ; checks the number in the variable "Index" and increases it by 1, each time you press esc.
    if (Index = MaxIndex+1) ; when the specific amount of words is exceeded
        Index := 1      ; set this variable to 1
        MyArray := []   ; recreate the object (empty the array)
    MyArray.Insert(Index, clipboard)    
Sleep, 300
clipboard := ClipSaved  ; restore original clipboard

f1:: SendInput, % MyArray[1]
f2:: SendInput, % MyArray[2]
f12:: SendInput, % MyArray[12]

For better understanding the whole context, read https://www.autohotkey.com/docs/Tutorial.htm#s7

  • Wow, thank you so much for this answer, it really works as I hoped it would, perfect! :) Just one more thing. Your code empties the array when we copied a specific amount of words. Would it be possible to change your if-statement so when a specific button is pressed, that it empties the array? – tenepolis Jan 24 '17 at 20:56
  • Add a hotkey that does the same thing as the auto-execute section (MyArray := [] and Index := 0). – user3419297 Jan 24 '17 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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