Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Disable all mouse buttons (temporarily)?



  • Please log in to reply
5 replies to this topic
duppy
  • Members
  • 13 posts
  • Last active: Oct 31 2015 02:14 AM
  • Joined: 16 May 2013

Uhm, I can't seem to find an autohotkey script to disable my mouse buttons.  I tried to figure it out myself, but I'm a bit too new to autohotkey scripting and I've only lightly skimmed over the manual, so my attempt didn't turn out so well. 

 

Really, I just want to disable my mouse buttons temporarily so I can clean my mouse.  You might say I should just turn off my computer, or unplug the mouse, or maybe download some other program that disables the mouse, but I thought surely AutoHotkey could easily accomplish this.  Sadly I couldn't find a pre-made script like I usual do, so that's why I'm here....well, after attempting to write my own script.

 

So, ideally I'd like *all* buttons disabled, including middle and side buttonsl (MButton, XButton1, and XButton2 I think it is), and then some keyboard shortcut that toggles between enabled and disabled states.  I could live with just left and right click disabled, but anyway, if anyone can help with that, I'd really appreciate it.

 

Here's may attempt which kinda-sorta works, but only for left and right mouse buttons...and for some reason right mouse button 'up' state still works when 'disabled'.

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

global toggle := 1   

rclick() {
    if toggle = 1
    {
        Click right
    }
    ; else nothing (disabled)
}

lclick() {
    if toggle = 1
    {
        Click left
    }
    ; else nothing (disabled)
}

return

#/::    ; Win+forward slash toggles
toggle := !toggle        
if toggle = 1
{
    tooltip "mouse buttons enabled"
    sleep 2000
    tooltip
}
else
{
    tooltip "mouse buttons disabled"
    sleep 2000
    tooltip
}
return

; change right clicking behavior
RButton::
rclick()
return

; change left clicking behavior
LButton::
lclick()
return

; if something screws up, CTRL+RButton will act as right click
^RButton::Click right down
^RButton up::Click right up

; if something screws up, CTRL+LButton will act as left click
^LButton::Click left down
^LButton up::Click left up

return

 

 



kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013

Try this: Edit: Nevermind, this just blocks movement, not buttons.

#m::                    ;win + m hotkey
if (x != 1)
{
    BlockInput, MouseMove
    x := 1
    return
}
if (x = 1)
{
    BlockInput, MouseMoveOff
    x := 0
    return
}


rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011
#NoEnv
#SingleInstance force 

^LButton:Click
^RButton::Click Right 

#If Toggle
LButton::return
RButton::return
MButton::return
XButton1::return
XButton2::return
#/::Toggle := not Toggle

See Hotkeys

See Tutorial


My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!


kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013
✓  Best Answer

This blocks buttons too:

#m::                    ;win + m hotkey
if (x != 1)
{
    BlockInput, MouseMove
    x := 1
    Hotkey, LButton, DoNothing
    Hotkey, RButton, DoNothing
    Hotkey, XButton1, DoNothing
    Hotkey, XButton2, DoNothing
    return
}
if (x = 1)
    reload

DoNothing:
return

ahhh - too slow



duppy
  • Members
  • 13 posts
  • Last active: Oct 31 2015 02:14 AM
  • Joined: 16 May 2013

Thanks, Kon, your second script seems to work best for what I was asking.  Using the Reload command was a good idea to restore the buttons back to their normal functions.

 

I tried rbrtryn's, but the toggle key was never assigned since it was after the #If section. I tried adding a return statement so it would be assigned and it still didn't work for me...*shrug*.  I will fool around with it though because I do like how the #if toggle lines make everything cleaner.

 

Much appreciated guys.



rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011

I tried rbrtryn's, but the toggle key was never assigned since it was after the #If section.


Sorry shy.gif, I should have tested before I posted. This should work better.
#NoEnv
#SingleInstance force 

Toggle := 0

#/::Toggle := not Toggle

^LButton::Send {Click}
^RButton::Send {Click Right}

#If Toggle
LButton::return
RButton::return
MButton::return
XButton1::return
XButton2::return

My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!