is there anyway to use setkeydelay for just a part of a large script (not the whole script)? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 07:47

so this is a small part of a large script (3000 lines). what i want to do is to remove delays of this part and make Controlsend as fast as possible so i need to use "setkeydelay" in auto-execute but that would break down some other parts of the script, is there any way to limit setkeydelay to just this part of the script? i don't want to use another .ahk file for this purpose:

Code: Select all

#if !WinActive("ahk_class CabinetWClass") && MouseOver("ahk_class CabinetWClass")
$WheelUp::
	ControlSend, ahk_class CabinetWClass, {Click}{WheelUp}
	WinActivate
	return

$WheelDown::
	ControlSend, ahk_class CabinetWClass, {Click}{WheelDown}
	WinActivate
	return
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 08:39

evilC wrote:SetKeyDelay is not just for the auto-execute section.
You could put a SetKeyDelay before and after the controlsend...
so, I should put the same setkeydelay exactly before and after of my controlsend? like this?

Code: Select all

setkeydelay 12
controlsend, control1, wintitle
setkeydelay 12
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 10:07

no, as that would have no effect.

If you had SetKeyDelay, 50 in your auto-exec section, then you could do like

Code: Select all

setkeydelay 12
controlsend, control1, wintitle
setkeydelay 50
This would leave the default value as 50, but the controlsend would use 12
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 11:30

evilC wrote:no, as that would have no effect.

If you had SetKeyDelay, 50 in your auto-exec section, then you could do like

Code: Select all

setkeydelay 12
controlsend, control1, wintitle
setkeydelay 50
This would leave the default value as 50, but the controlsend would use 12
thanks evilC :)
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 11:57

SetKeyDelay wrote:Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).
That is, you don't need to restore the default.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

11 Oct 2016, 16:09

Sorry, I should quantify "default" in my statement above.
I just meant the parameters you set by placing SetKeyDelay in the autoexecute section - you now consider that your "default" setting.

So I was saying to put a SetKeyDelay before your controlsend to set the parameters you want in effect for the controlsend, then after the controlsend, re-set your "default" setting again using another SetKeyDelay.
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

12 Oct 2016, 04:49

evilC wrote:Sorry, I should quantify "default" in my statement above.
I just meant the parameters you set by placing SetKeyDelay in the autoexecute section - you now consider that your "default" setting.

So I was saying to put a SetKeyDelay before your controlsend to set the parameters you want in effect for the controlsend, then after the controlsend, re-set your "default" setting again using another SetKeyDelay.
so your second reply in this thread is still true, right? cause i just need default (the delay that is between keys by default when you don't have any setkeydelay in your script) setkeydelay in a couple part of my script, but i need it as fast as possible everywhere else. so i guess i should use SetKeyDelay, 10, -1 in auto-execute to retain default, and use setkeydelay, -1,-1 anywhere that i don't want any delay, then again use SetKeyDelay, 10, -1 to restore the default
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

13 Oct 2016, 17:19

evilC wrote:Correct, but if your "normal" setting (The one you want for everything but the controlsend) is the same as the default setting, you would not need it in the auto-execute section.
i did like you said but the Capslock & d would imidiately bring up the delete message in WExplorer, that means the delay dousen't apply to it, what's wrong?

Code: Select all

;... Line: 1524 ...
#IfWinActive, ahk_exe Explorer.EXE

SetKeyDelay, 2000, 2000
CapsLock & d::
	KeyWait capslock
	Send +{Delete}
	return
	
SetKeyDelay, 10, -1	; restoring the default delay between keys

;... Line: 1532
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?  Topic is solved

14 Oct 2016, 01:09

Put the commands inside the hotkeyroutine. And, you have realise that after the #if expression has been evaluated, the execution is not continued on the line immediately beneath it, the execution will continue in the hotkey routine, if the #if expression evaluated to true. If it was false, the execution will continue where it was when the hotkey was pressed, or if there are other variants of the hotkey, it will continue there. Also, the line beneath the return isn't executed either.
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

14 Oct 2016, 11:30

Helgef wrote:Put the commands inside the hotkeyroutine. And, you have realise that after the #if expression has been evaluated, the execution is not continued on the line immediately beneath it, the execution will continue in the hotkey routine, if the #if expression evaluated to true. If it was false, the execution will continue where it was when the hotkey was pressed, or if there are other variants of the hotkey, it will continue there. Also, the line beneath the return isn't executed either.
you mean like this right?

Code: Select all

#IfWinActive, ahk_exe Explorer.EXE
CapsLock & d::
	SetKeyDelay, 2000, 2000
	KeyWait capslock
	Send +{Delete}
	return
	
Helgef wrote:Put the commands inside the hotkeyroutine
what douse hotkeyroutine means? you mean execution from a hotkey to another?
Helgef wrote:Also, the line beneath the return isn't executed either.
yeah that makes sense with what I previously read somewhere, but according to doc the next lines will execute with the default setkeydelay, right? (I don't have setkeydelay in my auto-execute) because the evilC said I should use it this way (his second comment in this thread), or I got him wrong, idk.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

14 Oct 2016, 23:57

DeepMind wrote: you mean like this right?
Yes
what douse hotkeyroutine means? you mean execution from a hotkey to another?
No, I just mean the code after the capslock & d:: down to the return (inclusive)
DeepMind
Posts: 271
Joined: 19 Jul 2016, 14:47

Re: is there anyway to use setkeydelay for just a part of a large script (not the whole script)?

17 Oct 2016, 12:05

Helgef wrote:
DeepMind wrote: you mean like this right?
Yes
what douse hotkeyroutine means? you mean execution from a hotkey to another?
No, I just mean the code after the capslock & d:: down to the return (inclusive)
thanks helgef, I really needed to get it to work

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Joey5 and 257 guests