Locking Desktop and Disabling Mouse

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lj87
Posts: 13
Joined: 06 Dec 2015, 18:47

Locking Desktop and Disabling Mouse

24 Mar 2017, 19:34

Hi,

Currently my computer refuses to let me disable the Mouse or Keyboard to wake the computer, so I'm hoping it can be done with AHK using BlockInput somehow. Problem is I have no idea where in my current Lock Desktop script to add the code for it to work properly. I tried adding it in a few places, but all it did was disable the mouse when I unlocked the desktop - the mouse still moved on the lockscreen.

Current script is

Code: Select all

#Esc::
Sleep, 1000
DllCall("LockWorkStation")
Sleep, 2000
SendMessage,0x112,0xF170,2,,Program Manager

Hopefully it's simple and someone can help me out.

Thanks
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Locking Desktop and Disabling Mouse

25 Mar 2017, 05:12

How are you going to wake up the computer without mouse or keyboard?

BlockInput is only 'processed' by Windows after the wake-up event, so it's not going to help you. Luckily DSpider solved a similar problem: [SOLVED] Turn off the monitor (and block mouse movement) when pressing "Win+Z"
lj87
Posts: 13
Joined: 06 Dec 2015, 18:47

Re: Locking Desktop and Disabling Mouse

25 Mar 2017, 06:53

Thanks for that link - that method works nicely. Do you think it would be possible for the mouse to auto unlock itself upon the desktop unlocking?
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Locking Desktop and Disabling Mouse

25 Mar 2017, 09:44

I use the following to change the standby timeout of my monitor on logoff/logon. You can easily change those Run lines to the script that re-enables your mouse:

Code: Select all

WM_WTSSESSION_CHANGE(wParam, lParam, Msg, hWnd){
	static init:=(DllCall( "Wtsapi32.dll\WTSRegisterSessionNotification", UInt, A_ScriptHwnd, UInt, 1) && OnMessage(0x02B1, "WM_WTSSESSION_CHANGE"))
	,_:={base:{__Delete: "WM_WTSSESSION_CHANGE"}}
	
	if !(_)
		DllCall("Wtsapi32.dll\WTSUnRegisterSessionNotification", "UInt", hWnd)
	
	If (wParam=0x6 || wParam=0x7){ ;Logoff or lock
		Run, powercfg -change -monitor-timeout-ac 1,,Hide ;Set monitor standby timeout to 1 minute
	}Else If (wParam=0x5 || wParam=0x8){ ;Logon or unlock
		Run, powercfg -change -monitor-timeout-ac 20,,Hide ;Set monitor standby timeout to 20 minutes
	}
	
			/*
			wParam::::::
			WTS_CONSOLE_CONNECT := 0x1 ; A session was connected to the console terminal.
			WTS_CONSOLE_DISCONNECT := 0x2 ; A session was disconnected from the console terminal.
			WTS_REMOTE_CONNECT := 0x3 ; A session was connected to the remote terminal.
			WTS_REMOTE_DISCONNECT := 0x4 ; A session was disconnected from the remote terminal.
			WTS_SESSION_LOGON := 0x5 ; A user has logged on to the session.
			WTS_SESSION_LOGOFF := 0x6 ; A user has logged off the session.
			WTS_SESSION_LOCK := 0x7 ; A session has been locked.
			WTS_SESSION_UNLOCK := 0x8 ; A session has been unlocked.
			WTS_SESSION_REMOTE_CONTROL := 0x9 ; A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.
			*/
}
lj87
Posts: 13
Joined: 06 Dec 2015, 18:47

Re: Locking Desktop and Disabling Mouse

26 Mar 2017, 03:54

Thanks for that. I tried adding the path in the run line, like this:

Code: Select all

If (wParam=0x6 || wParam=0x7){ ;Logoff or lock
		Run, "C:\AutoHotkeyDisableMouse\mouse_disable.vbs"
	}Else If (wParam=0x5 || wParam=0x8){ ;Logon or unlock
		Run, "C:\AutoHotkeyDisableMouse\mouse_enable.vbs"
Tried with and without the quotation marks, but no go. I'll just stick with the first method and hit space to unlock the mouse.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Panaku, Rohwedder, roysubs and 315 guests