Why is replaced text erasure inconsistent?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Wpq
Posts: 14
Joined: 02 Mar 2021, 04:15
Location: France

Why is replaced text erasure inconsistent?

Post by Wpq » 03 Aug 2022, 02:11

I wrote a simple sequence to bootstrap code blocks such as

Code: Select all

```python

```
The code below works most of the time:

Code: Select all

::mdcode::
{
  Lang := InputBox(,  "input MD code language")
  Send "{U+0060}{U+0060}{U+0060}" . Lang.Value . "`n`n`n{U+0060}{U+0060}{U+0060}{Up}"
}
Sometimes (this is hardly reproducible), some of the letters of "mdcode" are not erased and I end up with

Code: Select all

mdc```python

```
(the number of letters remaining vary, it can be one, it can be three, ...)

I guess that there is some kind of timing issue where the building of the code block is started before the replacement of mdcode is done. Is this something fixable?
Last edited by Wpq on 09 Aug 2022, 07:28, edited 1 time in total.

Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Why is replaced text erasure inconsistent?

Post by Rohwedder » 03 Aug 2022, 03:12

Hallo,
only a try:

Code: Select all

::mdcode::
{
  Sleep 100
  CaretGetPos(&CaretX, &CaretY)
  Lang := InputBox(,  "input MD code language")
  Send "{U+0060}{U+0060}{U+0060}" . Lang.Value . "`n`n`n{U+0060}{U+0060}{U+0060}{Up}"
}

Post Reply

Return to “Ask for Help (v1)”