Lbutton command ruins regular click Topic is solved

Ask gaming related questions
Eros

Lbutton command ruins regular click  Topic is solved

Post by Eros » 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: 2515
Joined: 13 May 2014, 17:15

Re: Lbutton command ruins regular click

Post by BoBo » 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: 4341
Joined: 27 Feb 2014, 12:30

Re: Lbutton command ruins regular click

Post by evilC » 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
Post Reply

Return to “Gaming”