Would this work as a remap? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
jellopudding
Posts: 6
Joined: 04 Aug 2016, 11:30

Would this work as a remap?

27 Mar 2024, 10:11

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?
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Would this work as a remap?

27 Mar 2024, 10:22

What are you trying to accomplish by mapping a button to itself?
User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: Would this work as a remap?

27 Mar 2024, 10:28

  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.
jellopudding
Posts: 6
Joined: 04 Aug 2016, 11:30

Re: Would this work as a remap?

27 Mar 2024, 11:09

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.
User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

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

27 Mar 2024, 11:17

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
jellopudding
Posts: 6
Joined: 04 Aug 2016, 11:30

Re: Would this work as a remap?

27 Mar 2024, 11:55

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.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Dav22, TAC109, vmech and 114 guests