Sleep/shutdown pc via mouse action Topic is solved
Sleep/shutdown pc via mouse action
Hi! I have a simple bluetooth computer mouse (right/left button and scroll wheel) - Logitech M185. I would like to put the computer to sleep or shutdown by holding pressed both buttons (left and right) at the same time for a certain period of time e.g. 10 seconds. I wonder if it is possible and how to do it. Thank you in advance for your help.
Re: Sleep/shutdown pc via mouse action Topic is solved
Welcome to this AutoHotkey forum!
Code: Select all
~LButton & ~RButton::
SetTimer, Go, -2000
SoundBeep, 1500
Return
~LButton Up::
~RButton Up::SetTimer, Go, Off
Go:
SoundBeep, 1000
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) ; Sleep computer
Return
Re: Sleep/shutdown pc via mouse action
Thank you so much! Work perfect. You are awesome
Re: Sleep/shutdown pc via mouse action
I have a question how to modify this script so that pressing the mouse buttons works also the other way. Now the order is: ~LButton & ~RButton:: This means that I can press the left button first and keep it e.g. for 1 minute, and next add the right mouse button. The action (timer) will start only when both are pressed, but the first (starting the sequence) must be the left button (~LButton). I want the action to be executed regardless of which key starts the sequence, that is: ~LButton & ~RButton:: = ~RLButton & ~LButton:: I am asking because it happens that when the keys are pressed simultaneously, the right button is pressed by some fractions of a millisecond faster than the left button and then the action does not work. Invariably, thank you in advance for your time and help
Re: Sleep/shutdown pc via mouse action
Of course, in the previous post it should be: ~LButton & ~RButton:: = ~RButton & ~LButton::
I can't modify a bug.
I can't modify a bug.
Re: Sleep/shutdown pc via mouse action
You can add a line to the top of the script.
Code: Select all
~RButton & ~LButton::