Making a toggle key for 'BlockInput MouseMove/Off'

Ask gaming related questions (AHK v1.1 and older)
saspoon
Posts: 5
Joined: 03 Apr 2018, 00:48

Making a toggle key for 'BlockInput MouseMove/Off'

03 Apr 2018, 01:05

Since 'BlockInput MouseMove' doesn't block MButton/Wheeldown/Wheeldown (I tested it) , but just axis movements,

I'd like to make a toggle key (Mbutton) to turn on/off this 'BlockInput MouseMove/MouseMoveOff' AHK statement.

I'm new to AHK and pretty much to all the other programming languages. Pls be patient on where I got wrong below.

(I'm not even sure the way that I put the variable is correct)

Code: Select all

Mouse_Blocked := false

$~MButton:: 


If (Mouse_Blocked := false)

{       KeyWait MButton  ;
        BlockInput MouseMove  ;
        Mouse_Blocked := true
        return
}




else If (Mouse_Blocked := true)

{       KeyWait MButton  ;
        BlockInput MouseMoveOff  ;
        Mouse_Blocked := false
        return    
}

I found out this works but it's working when the key is pressed down

Code: Select all

Loop
{
	
	if (GetKeyState("MButton"))
	{
		BlockInput MouseMove
	}
	else 
	{
		BlockInput MouseMoveOff
	}}
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Making a toggle key for 'BlockInput MouseMove/Off'

03 Apr 2018, 02:05

Your first script would work, however you have a small error in the if statements which stops it working, you are using ":=" which is only ever for assigning a value, and can never be used for checking a value. So you need to change the := to = but only in the two if statements.

The code could be cleaned up a bit, but otherwise it's a good effort for someone learning, it's essentially only the one repeated mistake you made.
saspoon
Posts: 5
Joined: 03 Apr 2018, 00:48

Re: Making a toggle key for 'BlockInput MouseMove/Off'

03 Apr 2018, 05:49

Thanks, it works what you replied.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 59 guests