Lbutton command ruins regular click Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Eros

Lbutton command ruins regular click  Topic is solved

22 Jan 2018, 03:15

Hello, I'm wondering why when I use the following script windows no longer recognizes my left mouse button down as a click. Why?

Code: Select all

Pause::Mbutton
lbutton::	
lbutton_count++    	
	If (lbutton_count = 1) 
	{
		Send {3}
	}
	If (lbutton_count = 2) 
	{
		Send {2}
	}
	If (lbutton_count = 2)
	{
		lbutton_count := 0
	}

	return 


Also, this pause doesn't work and I'd like to know why as well. I'm trying to make one keybind to turn it on or off on middle mouse wheel down. Main problem is the click though. Ty in advance!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Lbutton command ruins regular click

22 Jan 2018, 03:29

Code: Select all

Pause::Mbutton
lbutton::	
lbutton_count++   	
	If (lbutton_count = 1) {
	   Send, 3
	   }
	If (lbutton_count = 2) {
	   Send, 2
	   }
	If (lbutton_count > 2) {
       lbutton_count := 0
	   }
	Return
Not tested.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Lbutton command ruins regular click

22 Jan 2018, 08:42

It does not recognize lbutton as a click because you blocked lbutton.
lbutton:: will fire the code and block lbutton.
~lbutton:: will fire the code and NOT block lbutton.

Also I doubt you want this code

Code: Select all

lbutton::	
lbutton_count++   	
	If (lbutton_count = 1) {
	   Send, 3
	   }
	If (lbutton_count = 2) {
	   Send, 2
	   }
	If (lbutton_count > 2) {
       lbutton_count := 0
	   }
	Return
On the 3rd press of lbutton, no key will be sent. All it will do is set lbutton_count to 0.
Also, the code is CPU inefficient, as you do not use if/else. If lbutton_count is 1, it cannot also be 2, so no point in repeating the if check.

I think you probably want:

Code: Select all

lbutton::	
	lbutton_count++   	
	If (lbutton_count > 2) {
		lbutton_count := 1
	}
	If (lbutton_count = 1) {
		Send, 3
	} else if (lbutton_count = 2) {
		Send, 2
	}
	Return
Hell, you do not even need the if blocks anyway, just do

Code: Select all

lbutton::	
	lbutton_count++   	
	If (lbutton_count > 2) {
		lbutton_count := 1
	}
	Send % 4 - lbutton_count
	Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Shoobis and 39 guests