How to Duplicate a line using AHK? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
yfjuu6
Posts: 118
Joined: 28 Apr 2023, 15:28

How to Duplicate a line using AHK?

Post by yfjuu6 » 09 Jun 2023, 15:38

How to Duplicate a line in Anki Add editor using AHK?
I've tried this :

Code: Select all

^k::
send ^c
Sleep, 200
send {Down}{Enter}{up}
Sleep, 200
send ^v
Return
But this works well when a line is not at the end, but it has a problem with a last line in any document.
- Is there any commands to do so? Thanks.

User avatar
mikeyww
Posts: 26600
Joined: 09 Sep 2014, 18:38

Re: How to Duplicate a line using AHK?  Topic is solved

Post by mikeyww » 09 Jun 2023, 21:21

Code: Select all

#Requires AutoHotkey v1.1.33

#If WinActive("Add ahk_exe anki.exe")
^k Up::
Clipboard := ""
Send {End}+{Home}^c
ClipWait 0
If ErrorLevel
 MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send {End}`n^v
Return
#If

User avatar
kunkel321
Posts: 975
Joined: 30 Nov 2015, 21:19

Re: How to Duplicate a line using AHK?

Post by kunkel321 » 10 Jun 2023, 10:02

Here's the one I use.

Code: Select all

#IfWinActive, CodeQuick|SciTE4AutoHotkey|Adventure|AHK Studio|Pulover
!c:: ; Line duplicator
send {End}
send +{Home}
send ^c
send {};
send ^v
send {Enter}
send ^v
send {Alt up}
return
#IfWinActive,
Comments the line, then puts a duplicate below it. Mostly works.
Note that my auto exe section includes SetTitleMatchMode, RegEx
ste(phen|ve) kunkel

Post Reply

Return to “Ask for Help (v1)”