Copy and Paste Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Reast
Posts: 2
Joined: 20 May 2018, 09:04

Copy and Paste

20 May 2018, 09:14

Hi, i need simple script that copy selected text with F6 to file on desktop mix.txt, and next time F6 add selected text at the end of that file. I try to do myself but i am new to this.
wolf_II
Posts: 2271
Joined: 08 Feb 2015, 20:55

Re: Copy and Paste  Topic is solved

20 May 2018, 13:58

Try this simple code:

Code: Select all



; hotkey to collect selected texts in a file
;-------------------------------------------------------------------------------
F6:: FileAppend, % get_Highlight(), %A_Desktop%\mix.txt
;-------------------------------------------------------------------------------



;-------------------------------------------------------------------------------
get_Highlight() { ; get highlighted text
;-------------------------------------------------------------------------------
    ClipStore := ClipboardAll           ; remember current content
    Send, ^c                            ; copy highlighted text
    ClipWait, 1                         ; wait for change
    Result := Clipboard                 ; store highlighted text
    Clipboard := ClipStore              ; restore previous content
    Return, Result
}
I hope that helps.

More sophisticated is with a delimiter:

Code: Select all

#NoEnv
#SingleInstance, Force
Delimiter := "`n`n"
Return ; end of auto-execute section



; hotkey to collect selected texts in a file
;-------------------------------------------------------------------------------
F6:: FileAppend, % get_Highlight() Delimiter, %A_Desktop%\mix.txt
;-------------------------------------------------------------------------------



;-------------------------------------------------------------------------------
get_Highlight() { ; get highlighted text
;-------------------------------------------------------------------------------
    ClipStore := ClipboardAll           ; remember current content
    Send, ^c                            ; copy highlighted text
    ClipWait, 1                         ; wait for change
    Result := Clipboard                 ; store highlighted text
    Clipboard := ClipStore              ; restore previous content
    Return, Result
}
Reast
Posts: 2
Joined: 20 May 2018, 09:04

Re: Copy and Paste

20 May 2018, 14:30

Work great, thank you very much:)

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], TAC109, wyw and 48 guests