Simple script to block my mouse Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Fillo
Posts: 2
Joined: 30 Mar 2023, 16:00

Simple script to block my mouse

Post by Fillo » 30 Mar 2023, 16:13

Hi,
I am new to the forum and to the AHK scripting. I have made very simple script to disable and enable my mouse with different keys but it doesn't work. Have you got any sugestion what I am doing wrong? Please help.

What I want to do?
After pressing f key I want to disable my mouse and after presssing combination of ctrl+c I want to enable my mouse.


Code: Select all

f::
{
    BlockTheMouse := true
    BlockInput MouseMove
    return
}

if (BlockTheMouse)
{
    LButton::
    RButton::
    MButton::
    WheelUp::
    WheelDown::
    return
}

else
{
    ^c::
    BlockInput MouseMoveOff
    BlockTheMouse:= false
    return
}

User avatar
mikeyww
Posts: 26597
Joined: 09 Sep 2014, 18:38

Re: Simple script to block my mouse  Topic is solved

Post by mikeyww » 30 Mar 2023, 18:22

Welcome to this AutoHotkey forum!

Hotkeys are not defined under If or Else.

Code: Select all

; This script blocks mouse movement, mouse buttons, and wheel
#Requires AutoHotkey v2.0
BlockTheMouse := False

f:: {
 Global BlockTheMouse := True
 BlockInput 'MouseMove'
 SoundBeep 1500
}

^c:: {
 Global BlockTheMouse:= False
 BlockInput 'MouseMoveOff'
 SoundBeep 1000
}

#HotIf BlockTheMouse
LButton::
RButton::
MButton::
XButton1::
XButton2::
WheelUp::
WheelDown::
WheelLeft::
WheelRight::Return
#HotIf

Fillo
Posts: 2
Joined: 30 Mar 2023, 16:00

Re: Simple script to block my mouse

Post by Fillo » 31 Mar 2023, 05:58

Thank you for your help. I appreciate it very much.

The script works perfectly.

Post Reply

Return to “Ask for Help (v2)”