Fastest Script Optimization?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ositoMalvado
Posts: 183
Joined: 24 Dec 2019, 12:02
Contact:

Fastest Script Optimization?

Post by ositoMalvado » 21 Jun 2021, 17:18

Hi Guys, I know the next code is a good optimization for script speed

Code: Select all

#NoEnv
Process, Priority, , H
SetBatchLines, -1
ListLines Off
#KeyHistory 0
SendMode Input
SetTitleMatchMode 2
SetTitleMatchMode Fast
SetKeyDelay, -1, -1, Play
SetMouseDelay, -1
SetWinDelay, 0	
SetControlDelay, 0
SetDefaultMouseSpeed, 0
But I want to know how can I reach the REAL MAX speed to do the next:

Code: Select all

while GetKeyState("X", "P"){
	Clipboard:="HELLO WORLD!"
	send, {enter}^v{enter}
	;Sleep, 1 (? What is the minimum value before get a bug ?
}
or

Code: Select all

while GetKeyState("X", "P"){
	Clipboard:="HELLO WORLD!"
	send, ^v{enter}
	;Sleep, 1 (? What is the minimum value before get a bug ?
}
User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Fastest Script Optimization?

Post by mikeyww » 22 Jun 2021, 04:54

Use ClipWait. This sort of script-- rapid clipboarding inside a loop-- is often a problem because the clipboard is inherently slow. I'm not sure what its practical application would be. If you want to send the same text, use another variable, or you can put the clipboard assignment before your loop, or just send the text instead of using a variable.
Post Reply

Return to “Ask for Help (v1)”