Page 1 of 1

How to block a key's native function for only part of the code

Posted: 24 Jan 2019, 14:21
by Darion
Hello everyone. Here is my example for editing left mouse-clicking, it has two functions:
1. When un-toggled, LButton's function retained, pass all original left-clicks;
2. When toggled, LButton's function retained, unless LButton is held down for more than 1s (spam Space in this case).

Code: Select all

~LButton::
	If (!Toggle)
		return								; Changes nothing when un-toggled
	KeyWait LButton, T1						; When toggled, wait 1s for releasing LButton
	If ErrorLevel							; LButton still held down
		While GetKeyState("LButton", "P"){	; When LButton is held down
			Send, {Space}
			Sleep 100						; Spam Space
		}
	return
However, I found in the case of spaming Space, it also spams LButton as well, which is what I want to block (to only spam Space).

So I wonder is there a specific command for blocking a key's native function, only for the spam Space part of the code?
Or should I do it in some other way? Any help would be appreciated.

Re: How to block a key's native function while using ~ prefix

Posted: 24 Jan 2019, 14:48
by mast4rwang
if !toggle send {Click} ;d
also remove ~, add * because you will send click in your code.

Re: How to block a key's native function while using ~ prefix

Posted: 24 Jan 2019, 15:24
by Darion
mast4rwang wrote:
24 Jan 2019, 14:48
if !toggle send {Click} ;d
also remove ~, add * because you will send click in your code.
Thanks for the help.
At first I tried not using the ~ prefix and adding Send {Click}, but this would change the output of both single clicks AND holding down clicks into single clicks, which is not what I want.
Is there anyway to write the full click function (with holding down output), instead of just Send {Click}?

Re: How to block a key's native function while using ~ prefix

Posted: 25 Jan 2019, 10:59
by mast4rwang
Darion wrote:
24 Jan 2019, 15:24
mast4rwang wrote:
24 Jan 2019, 14:48
if !toggle send {Click} ;d
also remove ~, add * because you will send click in your code.
Thanks for the help.
At first I tried not using the ~ prefix and adding Send {Click}, but this would change the output of both single clicks AND holding down clicks into single clicks, which is not what I want.
Is there anyway to write the full click function (with holding down output), instead of just Send {Click}?
Yeah,

if !toggle
{
send,{LButton Down}
keywait,LButton
send,{LButton Up}
}

Re: How to block a key's native function while using ~ prefix

Posted: 27 Jan 2019, 18:17
by Darion
mast4rwang wrote:
24 Jan 2019, 14:48
if !toggle
{
send,{LButton Down}
keywait,LButton
send,{LButton Up}
}
You are the man, thank you!

Meanwhile I also find a solution to block the native function. In my case, add "Click, up" just before the part where Space loop begins.
Not sure how, but it also worked flawlessly. Posting here in case it helps someone.

Code: Select all

~LButton::
	if (!Toggle)
		return
	KeyWait LButton, T0.3
	Click, up
	if ErrorLevel
		while GetKeyState("LButton", "P"){
			Send, {Space}
			Sleep 100
		}
return