Page 1 of 1

Would this work as a remap?

Posted: 27 Mar 2024, 10:11
by jellopudding

Code: Select all

LButton::
		{
		Send ("{LButton down}")
		KeyWait "LButton"
		Send ("{LButton up}")
		}
Trying to make this remap and it seems to work fine so far. Do I lose any functionality of LButton by doing this?

Re: Would this work as a remap?

Posted: 27 Mar 2024, 10:22
by boiler
What are you trying to accomplish by mapping a button to itself?

Re: Would this work as a remap?

Posted: 27 Mar 2024, 10:28
by mikeyww
  1. This is not the same as a remap.
  2. Send will adjust modifier states to ensure that the keys or buttons are sent as stated.
  3. Your question can be answered by running your script, to see whether you notice any adverse effects.
  4. Individual (not custom combination) hotkeys without modifiers or a wildcard will not be triggered when modifiers are held.

Re: Would this work as a remap?

Posted: 27 Mar 2024, 11:09
by jellopudding

Code: Select all

#Requires AutoHotkey >=2.0
#SingleInstance Force
#HotIf WinActive("ahk_exe Chrome.exe")

toggle := 1

^b::
{
    Global toggle := !toggle
	SoundBeep 100, 200
}

LButton::
{	
	If toggle
		{
		Send ("{LButton down}")
		KeyWait "LButton"
		Send ("{LButton up}")
		}
	else
		{
		Loop
		{
		Send ("{LButton down}")
		Sleep 50
		Send ("{LButton up}")
		If not GetKeyState("LButton", "P")
		Break
		}
	}
}
Here's the full code. Trying to make LButton function normally and use toggle to turn it into rapid clicker.

Re: Would this work as a remap?  Topic is solved

Posted: 27 Mar 2024, 11:17
by mikeyww
Setting a context is better. It leaves your button alone when the context is not met.

Code: Select all

#Requires AutoHotkey v2.0
on     := False
chrome := 'ahk_exe chrome.exe'

#HotIf WinExist(chrome)
F12:: {
 Global on ^= True
 SoundBeep 1000 + 500 * on
}

#HotIf on && WinActive(chrome)
LButton::MsgBox
#HotIf

Re: Would this work as a remap?

Posted: 27 Mar 2024, 11:55
by jellopudding

Code: Select all

#Requires AutoHotkey >=2.0

AA     := False
chrome := 'ahk_exe chrome.exe'

#HotIf WinExist(chrome)
^b::
{
	Global AA ^= True
	SoundBeep 400 - 300 * AA
}


#HotIf AA && WinActive(chrome)
*LButton::
{
	Loop
	{
	Send ("{LButton down}")
	Sleep 80
	Send ("{LButton up}")
	If not GetKeyState("LButton", "P")
	Break
	}
}
Thank you so much, that was insanely helpful. I think I got it to work way it should.