Theoretical question

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ant1ksts
Posts: 10
Joined: 07 Dec 2015, 11:12

Theoretical question

28 May 2017, 16:14

Hello!
Could someone tell me, will such stroke of code be typed by AHK faster on more powerful computer without mess (like on video below)?

Code: Select all

::btw::by the way by the way by the way by the way by the way by the way by the way by the way
Attaching a video to illustrate the case.

https://youtu.be/NIyWCk5imBM

Thanks for every answer!
User avatar
mviens
Posts: 43
Joined: 08 Jan 2014, 19:04

Re: Theoretical question

28 May 2017, 17:50

Using HotStrings like that does tend to be very slow, in my experience. I have converted all of my HotStrings to use WIndows paste rather than using the built-in Send/SendPlay/SendRaw functions of AHK. Some of my HotStrings are around 10K or more and they paste instantly because it is not sending each individual character.

So, try something like this:

Code: Select all

pasteHotString(text:="") {
    prevClipboard := ClipboardAll
    Clipboard := text
    ClipWait()
    Sleep, 50
    SendInput, ^v
    ; wait or the clipboard is replaced with previous before it gets a chance to paste it, resulting in pasting the original clipboard
    Sleep, 250
    Clipboard := prevClipboard
    Sleep, 20
    prevClipboard := ""
}

::btw::
    pasteHotString("by the way by the way by the way by the way by the way by the way by the way by the way")
    return
The reason for the calls to Sleep is that on one of my computers, AHK will run the script faster than the actually processing of the commands and it ends up pasting the wrong thing. You can likely remove them safely.
Mike V.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Theoretical question

28 May 2017, 18:25

You can lso try SendInput mode :SI:btw::by the way by the way by the way by the way by the way by the way by the way by the way.
ant1ksts
Posts: 10
Joined: 07 Dec 2015, 11:12

Re: Theoretical question

30 May 2017, 15:11

HotKeyIt wrote:You can lso try SendInput mode :SI:btw::by the way by the way by the way by the way by the way by the way by the way by the way.
Thank you, but all variety of Send modes (Send, SI, SE, SP) are not good for me because of other options.
ant1ksts
Posts: 10
Joined: 07 Dec 2015, 11:12

Re: Theoretical question

30 May 2017, 15:12

mviens wrote:Using HotStrings like that does tend to be very slow, in my experience. I have converted all of my HotStrings to use WIndows paste rather than using the built-in Send/SendPlay/SendRaw functions of AHK. Some of my HotStrings are around 10K or more and they paste instantly because it is not sending each individual character.

So, try something like this:

Code: Select all

pasteHotString(text:="") {
    prevClipboard := ClipboardAll
    Clipboard := text
    ClipWait()
    Sleep, 50
    SendInput, ^v
    ; wait or the clipboard is replaced with previous before it gets a chance to paste it, resulting in pasting the original clipboard
    Sleep, 250
    Clipboard := prevClipboard
    Sleep, 20
    prevClipboard := ""
}

::btw::
    pasteHotString("by the way by the way by the way by the way by the way by the way by the way by the way")
    return
The reason for the calls to Sleep is that on one of my computers, AHK will run the script faster than the actually processing of the commands and it ends up pasting the wrong thing. You can likely remove them safely.
This code doesn't work properly on my computer. Sometimes it types "by the way by the way by the way by the way by the way by the way by the way by the way", then it starts typing just "v". That's it.
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Theoretical question

30 May 2017, 15:31

If it's sending just "v" then it is either missing the control press from the sendinput, or control is sticking. You could try making the control press explicit: SendInput, {ctrl down}v{ctrl up} and see if that makes a difference.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Theoretical question

30 May 2017, 17:02

This might be useful:
PostMessage plz help - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 65#p144465

It uses the WM_CHAR message, use PostMessage (which might be faster, and I haven't seen it to be unreliable), or if that is not reliable, SendMessage might be more reliable.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], jaka1 and 168 guests