Turn off screen updating for hotstrings

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Turn off screen updating for hotstrings

15 Apr 2021, 08:35

I recently upgraded from Win7 to Win10 and am noticing that the lengthy hotstrings which I had configured are now taking more than 10 seconds to complete as in Win10 I can see the text being 'typed' out instead of just happening in one go (would take about a second in Win7)..... In VB I had seen something similar where you would just put in the following code "Application.ScreenUpdating = False" - is there something similar to this in AHK?

thanks
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

15 Apr 2021, 08:50

It sounds like the default method of sending the characters for hotstrings, SendInput, is not being used. It may be because of what's described in the SendInput documentation:
SendInput documentation wrote:If a script other than the one executing SendInput has a low-level keyboard hook installed, SendInput automatically reverts to SendEvent (or SendPlay if SendMode InputThenPlay is in effect)
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

19 Apr 2021, 06:44

Thanks Boiler, have read that documentation but I don't see how that helps... am still not sure how to overcome this slowness with long hotstrings
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

19 Apr 2021, 09:09

What that implies is that you might have another script running that installs a keyboard hook, which then affects this one by not allowing SendInput mode to work. Do you have other scripts running?
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

23 Apr 2021, 00:17

When you say do I have other scripts running, I assume that you're referring to other AHK scripts? In which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch *only* my personal one the same screen updating behaviour is observed.

What I noticed just now though is that for notepad++ when I execute the looooong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text being 'typed' out (it's pretty quick in notepad and textpad, but for outlook it's way slower.... )

Have tried playing around with several SendInput variations.. may I ask if you were to run the below in the body of a new outlook email running on Win10 do you have the same issue?

Code: Select all

:r0:letstestthisout:: SendInput
(
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
)
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

23 Apr 2021, 04:17

Notice that your test isn’t executing the SendInput command. It is sending the actual string "SendInput" along with the text below it. To execute it, you either need to add the X hotstring option or put the command on the line below the hotstring, like this:

Code: Select all

:r0:letstestthisout::
SendInput,
(
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
)
return
Having said that, it takes a little time to “type out” the above test into Notepad for me, but nowhere near as long as if I change it to regular Send.
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

23 Apr 2021, 04:21

Here’s an approach that should immediately send all the text:

Code: Select all

:r0:letstestthisout::
ClipSave := ClipboardAll
Clipboard =
(
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
when you say do I have other scripts running, I assume that you're referring to other AHK scripts, in which case yes (I have a personal one and a shared one that have setup for the team)... however when I launch only my personal one the same screen updating behaviour is observed.
What I noticed just now though is that for notepad++ when I execute the looong hotstring it works as I would expect (and did for all applications in Win7)... however when I execute the same looong hotstring in Outlook email, textpad or notepad you get to see the text 
)
Send, ^v
Sleep, 500
Clipboard := ClipSave
return
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

23 Apr 2021, 20:51

Nice... you know what you're talking about Boiler... thank you!... I'm afraid to say however that I didn't give the best example... and as a result whilst the above does workaround the screen updating for the example I gave, it doesn't work for hotstrings which have {tab} {enter} functions as it's just copy pasting as is... for example

Code: Select all

:r0:letstestthisout::
ClipSave := ClipboardAll
Clipboard =
(
shorter example {enter}
see what I mean {tab 6}
)
Send, ^v
Sleep, 500
Clipboard := ClipSave
return
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

23 Apr 2021, 21:40

There's always a way...

Code: Select all

:xr0:letstestthisout::SmartPaste("
(
shorter example{enter}
see what I mean{tab 6}
)")

SmartPaste(str) {
	clipSave := ClipboardAll
	loop {
		RegExMatch(str, "^[^{]+", m)
		Clipboard := m
		Send, ^v
		str := SubStr(str, StrLen(Clipboard) + 1)
		RegExMatch(str, "^{.*?}", m)
		Send, % m
		str := SubStr(str, StrLen(m) + 1)
	} until str = ""
	Sleep, 500
	Clipboard := clipSave
}
By the way, your {enter} isn't really necessary since the line breaks are indicated by the actual line breaks, but that's okay. The {enter} will cause an extra linefeed.
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

27 Apr 2021, 03:19

Hi boiler, thank you for your time and effort on this, I've just tried out the code snippet and unfortunately that's not working.... let me play around with what you've provided and get back
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

27 Apr 2021, 06:16

Not working in what way? Did you run the script, then type letstestthisout followed by a space or the Enter key? Did it not produce anything?

I don’t see how it could not work. What happens when you type the trigger string followed by a space? Make sure you copy the whole script as is. Notice the hotstring definition itself is different in that it has an x in it.
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

07 May 2021, 01:26

Hi Boiler... had a bit of a play around with it and am unable to get it working - by not working I mean that the hotstring is still screen updating in real time...

I tried again just copy pasting the exact code you provided and even created an animated gif to show you but don't see how to add it to this reply as attachment
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

07 May 2021, 09:10

To attach a picture, after you click the "Reply" button, you can drag pictures into the text entry field, and it will attach the file. Then in the "Attachments" tab below the text entry field, click the "Place inline" button to place the image in your message at the point where your text entry cursor is located.
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

12 May 2021, 00:13

Nice...
2021-05-07_15-19-38.gif
2021-05-07_15-19-38.gif (432.77 KiB) Viewed 679 times
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

12 May 2021, 08:00

You apparently didn’t copy my script and tried to modify your existing script and didn’t catch all the changes. Notice the x in the hotstring options.
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

13 May 2021, 20:55

gif not as nice as last time, but in short the gif is trying to show:
1) copy the code snippet provided
2) paste the code snippet in .ahk file
3) save and reload .ahk
4) run hotstrings in email
2021-05-14.gif
2021-05-14.gif (939.19 KiB) Viewed 650 times
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

14 May 2021, 03:07

It's certainly doing exactly what it would do if you didn't include the x option. It's hard to tell from your latest gif, but based on the line numbers in your editor, it looks like you are pasting it into a much larger script, so I can't see what you have before it. If you had some other hotstring definition for the same shortcut ("letstestthisout") before it, that could be causing a problem, or perhaps something else. Can you exit any other scripts you have running, put this script into its own file, make sure the "x" option is present, and then try it?
gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: Turn off screen updating for hotstrings

14 May 2021, 05:49

Not sure, if it was already mentioned, but for the X option to work, you need at least AHK version 1.1.28.
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Turn off screen updating for hotstrings

14 May 2021, 07:31

Ah, I’m sure that’s it. Thanks, gregster!
lovingahk
Posts: 9
Joined: 15 Apr 2021, 08:28

Re: Turn off screen updating for hotstrings

17 May 2021, 20:27

yep... thanks for taking the time to help with this... you're right, we're on version v1.1.13 and not likely to upgrade

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], sbrady19 and 131 guests