Block all keyboard input except PgUp and PgDn.

Get help with using AutoHotkey and its commands and hotkeys
momo2000
Posts: 32
Joined: 25 Jan 2015, 12:00

Block all keyboard input except PgUp and PgDn.

29 Apr 2016, 13:52

I’ve got a laptop that will sit in a public space. People can view a PDF that will be loaded and already on the screen. I need a script that will disable/ignore ALL keyboard except PgUp and PgDn, so that they may view the PDF. I need to ignore all mouse input (buttons mostly, I don’t care if the mouse moves on the screen) except those two.

QUESTION: Is there a way to globally block all keys, and then allow/whitelist the TWO EXCEPTIONS? OR, so I have to go unallow/blacklist EVERY other combination I can think of (as in the script below). I’m just sure I will miss some.
My current script is below (forked from the 3rd post here: https://autohotkey.com/board/topic/8448 ... some-keys/)

Code: Select all

#SingleInstance force
Lwin::Return
Rwin::Return
BackSpace::Return
Delete::Return
Escape::Return
Lbutton::Return
Mbutton::Return
HotKeyIt
Posts: 1867
Joined: 29 Sep 2013, 18:35
Contact:

Re: Block all keyboard input except PgUp and PgDn.

29 Apr 2016, 14:54

Try:

Code: Select all

Loop {
	Input,v,,{PGDN}{PGUP}
	If InStr(ErrorLevel,"EndKey")
		Send % "{" SubStr(ErrorLevel,8) "}"
}
LButton::
MButton::
RButton::
momo2000
Posts: 32
Joined: 25 Jan 2015, 12:00

Re: Block all keyboard input except PgUp and PgDn.

29 Apr 2016, 15:29

WOW, yes, that is it! I never would have thought to come at it from that "angle". Nice. I'll go test for all keys, and see if I can figure any way around it . . . as I know folks will try lots of things . . . so I better try them first ;)
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: Block all keyboard input except PgUp and PgDn.

29 Apr 2016, 15:40

It isn't foolproof. Ctrl+Alt+Delete is probably still going to work. I don't think there is any particular way to prevent that, or interacting with it.

I did find that if you use Ctrl+Alt+Delete, Task Manager can be brought up and interacted with. Then AHK can be shut down. If you run the script as administrator, it stops that. However, I don't know how you would exit the script then. Using a single hotkey like the following script worked for me, but I'd imagine you'd like to have a combination hotkey or even a password to enter... I suppose that you can parse the v string for the value of the password and Exit the App, like this:

Code: Select all

password:="unlock"
Loop {
	Input,v,,{PGDN}{PGUP}
        If InStr(v,password)
                ExitApp
	If InStr(ErrorLevel,"EndKey")
		Send % "{" SubStr(ErrorLevel,8) "}"
}
LButton::
MButton::
RButton::
Just tested that, and it seems to work. Type the password in quotes and that is what needs to be typed (at any point in time) before a PgUp or PgDn is sent to unlock it.
momo2000
Posts: 32
Joined: 25 Jan 2015, 12:00

Re: Block all keyboard input except PgUp and PgDn.

29 Apr 2016, 17:24

Thanks, that gets me closer. The addition of:

Code: Select all

LWin Up:: Return 
that eliminates the Windows key. It seems that I have everything blocked but the CTRL-ALT-DEL, so still working on that. Ideas welcome.

Return to “Ask For Help”

Who is online

Users browsing this forum: arazu, Bing [Bot], FlizzyDuck, gongnl, Google [Bot], MIRKOSOFT, SOPMOD, Wigi and 143 guests