How to SendInput or paste without moving the caret (insertion point)?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
NorInd
Posts: 43
Joined: 03 May 2020, 04:23

How to SendInput or paste without moving the caret (insertion point)?

29 Dec 2020, 20:37

How to SendInput or paste without moving the caret (insertion point)?

I don't want to use the arrow key. ie: SendInput, {Left 2}
I want to literally stop the caret from moving.

2 reasons for that,
1. Move the caret back is too slow.
2. It might not move the caret back to its position in some case
(eg: when you press Enter in some code editor, because of auto indent, move back once will not be back at the original position.)

The code may be something like this::

Code: Select all

^+1::
  SendInput, AA*
  stopCaret() ; now the Caret should stop right after *, when this script is finished
  SendInput, BB
return

^+2::
  stopCaret() ; the Caret should stop at its original position, the thing you pasted should be after it
  SendInput, ^v
return
NorInd
Posts: 43
Joined: 03 May 2020, 04:23

Re: How to SendInput or paste without moving the caret (insertion point)?

09 Jul 2022, 11:11

### lintalist
I found a nice solution (workaround) by `lintalist`
list-nli wrote:
14 May 2016, 02:23
Just fyi my program Lintalist has a "plugin" which allows you to set the cursor position after pasting and you can use Selected or Clipboard text (an a variety of other plugins) https://autohotkey.com/boards/viewtopic.php?f=6&t=3378
So a snippet would look like:
<p><span class="subtitle">Title ^| [[clipboard]]:</span>
</p>
where [[clipboard]] is replaced by the clipboard content and ^| is where the caret will be placed.

The function where the position of ^| is calculated (the number of UP and LEFTS) is CheckCursorPos() here https://github.com/lintalist/lintalist/blob/master/lintalist.ahk#L1661
### How to use lintalist
0. download `lintalist` from https://github.com/lintalist/lintalist & open `lintalist.ahk`
1. Open `lintalist`
2. `F4` or `right click` to edit the snippet
3. add the ^| (caret position) & [[clipboard]] (clipboard content) to your snippet
4. assign a hotkey
5. save
6. press the hotkey -> you get the content of the snippet pasted +`caret` at the `^|` position + clipboard content included.
image.png
image.png (108.13 KiB) Viewed 482 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Google [Bot] and 186 guests