AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Toddler Keyboard

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
bobbo



Joined: 19 Mar 2007
Posts: 14

PostPosted: Fri Jun 29, 2007 3:14 am    Post subject: Toddler Keyboard Reply with quote

I've got a 1-year-old boy that's just starting to bang on the keyboard to this kind of game:
http://www.fisher-price.com/fp.aspx?st=2601&e=gamesByAge&mcat=game_infant&site=us

I've also got a 4-year-old girl who's starting to move up to side-scrollers:
http://www.nickjr.com/playtime/index.jhtml

My problem was they tended to bump the Windows key, or an Alt key, etc., and the game's window lost focus. (Or the 1-year-old somehow re-arranged all the desktop icons.) I looked for a long time for a kid's keyboard, or an overlay, or something, but it just doesn't exist.

So my answer was this simple script that does just two things: (1) disables all keys except the alpha-numerics and direction keys, and (2) for a held-down key, only sends a single key-press.

Code:
; Toddler Keyboard
; v1.0 29Jun2007
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         bobbo
;
; Script Function:
;    Prevents key presses to most keys other than A-F and 0-9.
;    Useful to prevent children's games from losing window focus.
;    Also only sends key press once if held down.
;
;-------------------------------------------------

#NoEnv ;
SendMode Input ;

;key list found at: http://www.autohotkey.com/docs/KeyList.htm

;-------------------------------------------------
;KEYS NOT ALLOWED:
;-------------------------------------------------

Tab::
Escape::
Backspace::

Delete::
Insert::
Home::
End::
PgUp::
PgDn::

ScrollLock::
CapsLock::
NumLock::

F1::
F2::
F3::
F4::
F5::
F6::
F7::
F8::
F9::
F10::
F11::
F12::
F13::
F14::
F15::
F16::
F17::
F18::
F19::
F20::
F21::
F22::
F23::
F24::

AppsKey::

LWin::
RWin::

LControl::
RControl::
LShift::
RShift::
LAlt::
RAlt::

PrintScreen::
CtrlBreak::
Pause::
Break::

Help::
Sleep::

Browser_Back::
Browser_Forward::
Browser_Refresh::
Browser_Stop::
Browser_Search::
Browser_Favorites::
Browser_Home::
Volume_Mute::
Volume_Down::
Volume_Up::
Media_Next::
Media_Prev::
Media_Stop::
Media_Play_Pause::
Launch_Mail::
Launch_Media::
Launch_App1::
Launch_App2::

;not an allowed key, so do nothing
return

;-------------------------------------------------
;KEYS ALLOWED:
;-------------------------------------------------

; I chose to let these through unaffected, to allow
; for certain game control
;Up::
;Down::
;Left::
;Right::
;Space::
;Enter::

Numpad0::
NumpadIns::
Numpad1::
NumpadEnd::
Numpad2::
NumpadDown::
Numpad3::
NumpadPgDn::
Numpad4::
NumpadLeft::
Numpad5::
NumpadClear::
Numpad6::
NumpadRight::
Numpad7::
NumpadHome::
Numpad8::
NumpadUp:
Numpad9::
NumpadPgUp::
NumpadDot::
NumpadDel::
NumpadDiv::
NumpadMult::
NumpadAdd::
NumpadSub::
NumpadEnter::

;only send the key press through once if held down continually
;(use curly brackets to send these special keys)
if (A_PriorHotkey <> A_ThisHotkey or A_TimeSincePriorHotkey > 500)
{
   Hotkey, %A_ThisHotkey%, Off
   Send, {%A_ThisHotkey%}
   Hotkey, %A_ThisHotkey%, On
}
return

a::
b::
c::
d::
e::
f::
g::
h::
i::
j::
k::
l::
m::
n::
o::
p::
q::
r::
s::
t::
u::
v::
w::
x::
y::
z::

0::
1::
2::
3::
4::
5::
6::
7::
8::
9::

;only send the key press through once if held down continually
;(send the literal keys)
if (A_PriorHotkey <> A_ThisHotkey or A_TimeSincePriorHotkey > 500)
{
   Hotkey, %A_ThisHotkey%, Off
   Send, %A_ThisHotkey%
   Hotkey, %A_ThisHotkey%, On
}
return

This script has really cut down on the, "Dad, fix the computer!" calls in my house; hope you find it useful, too.
Back to top
View user's profile Send private message
Dave72



Joined: 27 Jan 2007
Posts: 26
Location: Canada

PostPosted: Fri Jun 29, 2007 4:19 am    Post subject: Reply with quote

Fantastic.. I hadnt even thought of using ahk to lock-down the wife's pc like that for our 4 yr old to use..

Ill prob compile and install it tomorrow.

Thanks for thinking outside the box !
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6719
Location: France (near Paris)

PostPosted: Fri Jun 29, 2007 11:00 am    Post subject: Reply with quote

Good idea. In the past, I had found a freeware locking the Windows key using a hook DLL, and displaying fancy graphics depending on the key hits.
I also found that Tux Paint is a nice playing field for kids...
That said, I have found (in France) keyboard covers for kids, never bought one though.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
badmojo



Joined: 11 Nov 2005
Posts: 185

PostPosted: Sat Jun 30, 2007 10:06 am    Post subject: Reply with quote

great work, bobbo! previously i used Toddler Keys but this is very good and since it's in AHK i can easily adapt it to my needs.. hope you don't mind.. Wink
Back to top
View user's profile Send private message
airjrdn



Joined: 25 Feb 2008
Posts: 37

PostPosted: Sat Mar 29, 2008 12:21 pm    Post subject: Reply with quote

Be sure to check out the KidzCD's. I mirror them on my freeware site http://www.MissingBytes.net in the Kids section, but the main site can be found at http://www.kidzcd.com

Mine are 5, 4, 1.5, & 6mo, so I've been where you are now, but the tool you put together will be very useful, thanks for taking the time to do it.
Back to top
View user's profile Send private message
bmazic
Guest





PostPosted: Sat Dec 20, 2008 10:57 pm    Post subject: Toddler Keyboard - A variation Reply with quote

I know this is an old topic, but the theme is an everlasting one. I needed a slightly different thing, so I adapted the bobbo's script to suit my needs.

The idea behind the script is to disable all keyboard keys and mouse buttons by default, but allow the keyboard and mouse input by using a specific keyboard modifier - the left shift key. Whenever you need to use the keyboard or a mouse button, just hold the left shift key down. Read the comments in the script for the fuller description of the script's features.

What this means in practice is that you can surf the net, watch a movie, read a document, etc. while your dearest human being is banging against the keyboard. It is most useful for tasks that require few and occasional keyboard input.

Boris


Code:

; Toddler Keyboard
; v1.0 19dec2008
;
; AutoHotkey Version: 1.x
; Platform: WinNT/2k/XP
; Author:   Boris Mazic
;
; Script Function:
;   Based on bobbo's Toddler Keyboard script, but with the mind
;   on the parents using the computer, not the kids.
;
;   I have a kid that, like any other kid, feels a strong urge
;   to do whatever his dad is doing. Likewise so when it comes
;   to computers... It is next to impossible to surf the net or
;   watch a movie without him wanting to help a little, after all
;   all these keys are there to be pressed, banged against, popped
;   out, and what not. Are they not?!
;   
;   The idea behind the script is to allow some keyboard control,
;   while at the same time making the keyboard childproof. What
;   this means in practice is that you can surf the net, watch a
;   movie, read a document, etc. while your dearest human being
;   is banging against the keyboard. It is most useful for tasks
;   that require few and occasional keyboard input.
;
;   This is accomplished by disabling all keyboard keys and mouse
;   buttons by default, but allowing the keyboard and mouse input
;   by using a specific keyboard modifier. By default this is the
;   left shift key (you can change this relatively easy - just
;   search for TODO within this script and follow the instructions).
;
;   So, whenever you need a certain key combination, just add left
;   shift to it. For example, to paste a clipboard content, instead
;   of pressing Ctrl+V (which does nothing), press LShift+Ctrl+V. To
;   use mouse buttons, hold the left shift key down while pressing a
;   mouse button.
;
;   If you need a key combination that contains shift key, use right
;   shift key to do it: e.g. LShift+Ctrl+RShift+Space would produce
;   Ctrl+Shift+Space key combination.
;
;   You can suspend the script action by pressing LShift+Ctrl+Alt+S,
;   which will restore full keyboard access. Press Ctrl+Alt+S to enable
;   the script again.
;
;-------------------------------------------------

#NoEnv ;
SendMode Input ;


; TODO
; If you want a different keyboard modifier, make sure you change it here
; and all references to it in the section 'KEYS ALLOWED' below.
prefix := "LShift & "


ResendKey()
{
    global prefix
    key := A_ThisHotkey
    mod := (GetKeyState("RShift", "P") ? "+" : "")
    mod .= (GetKeyState("Alt", "P") ? "!" : "")
    mod .= (GetKeyState("Control", "P") ? "^" : "")
    mod .= (GetKeyState("LWin", "P") || GetKeyState("RWin", "P") ? "#" : "")
    key := RegExReplace(key, "^" . prefix . "\s*")
    hotkey := "*" . key

    Hotkey, %hotkey%, Off
    Send, %mod%{%key%}
    Hotkey, %hotkey%, On
}


;key list found at: http://www.autohotkey.com/docs/KeyList.htm


^!s::Suspend  ; Assign the toggle-suspend function to a hotkey.


;-------------------------------------------------
;KEYS NOT ALLOWED:
;-------------------------------------------------

; Mouse buttons

*LButton::
*RButton::
*MButton::

*WheelDown::
*WheelUp::

*XButton1::
*XButton2::


; Keyboard keys

*Tab::
*Escape::
*Backspace::

*Delete::
*Insert::
*Home::
*End::
*PgUp::
*PgDn::

*ScrollLock::
*CapsLock::
*NumLock::

*F1::
*F2::
*F3::
*F4::
*F5::
*F6::
*F7::
*F8::
*F9::
*F10::
*F11::
*F12::
*F13::
*F14::
*F15::
*F16::
*F17::
*F18::
*F19::
*F20::
*F21::
*F22::
*F23::
*F24::

*AppsKey::

*LWin::
*RWin::

*LControl::
*RControl::
*LShift::
*RShift::
*LAlt::
*RAlt::

*PrintScreen::
*CtrlBreak::
*Pause::
*Break::

*Help::
*Sleep::

*Browser_Back::
*Browser_Forward::
*Browser_Refresh::
*Browser_Stop::
*Browser_Search::
*Browser_Favorites::
*Browser_Home::
*Volume_Mute::
*Volume_Down::
*Volume_Up::
*Media_Next::
*Media_Prev::
*Media_Stop::
*Media_Play_Pause::
*Launch_Mail::
*Launch_Media::
*Launch_App1::
*Launch_App2::

*Up::
*Down::
*Left::
*Right::
*Space::
*Enter::

*Numpad0::
*NumpadIns::
*Numpad1::
*NumpadEnd::
*Numpad2::
*NumpadDown::
*Numpad3::
*NumpadPgDn::
*Numpad4::
*NumpadLeft::
*Numpad5::
*NumpadClear::
*Numpad6::
*NumpadRight::
*Numpad7::
*NumpadHome::
*Numpad8::
*NumpadUp:
*Numpad9::
*NumpadPgUp::
*NumpadDot::
*NumpadDel::
*NumpadDiv::
*NumpadMult::
*NumpadAdd::
*NumpadSub::
*NumpadEnter::

*a::
*b::
*c::
*d::
*e::
*f::
*g::
*h::
*i::
*j::
*k::
*l::
*m::
*n::
*o::
*p::
*q::
*r::
*s::
*t::
*u::
*v::
*w::
*x::
*y::
*z::

*0::
*1::
*2::
*3::
*4::
*5::
*6::
*7::
*8::
*9::

; keyboard specific keys
; TODO (change them according to your keyboard layout)
*š::
*đ::
*č::
*ć::
*ž::
*'::
*+::
*,::
*.::
*-::
*SC056::    ; <
*SC029::    ; CEDILLA

;not an allowed key, so do nothing
return

;-------------------------------------------------
;KEYS ALLOWED:
;-------------------------------------------------

; Mouse buttons

LShift & LButton::
LShift & RButton::
LShift & MButton::

LShift & WheelDown::
LShift & WheelUp::

LShift & XButton1::
LShift & XButton2::


; Keyboard keys

LShift & Tab::
LShift & Escape::
LShift & Backspace::

LShift & Delete::
LShift & Insert::
LShift & Home::
LShift & End::
LShift & PgUp::
LShift & PgDn::

LShift & ScrollLock::
LShift & CapsLock::
LShift & NumLock::

LShift & F1::
LShift & F2::
LShift & F3::
LShift & F4::
LShift & F5::
LShift & F6::
LShift & F7::
LShift & F8::
LShift & F9::
LShift & F10::
LShift & F11::
LShift & F12::
LShift & F13::
LShift & F14::
LShift & F15::
LShift & F16::
LShift & F17::
LShift & F18::
LShift & F19::
LShift & F20::
LShift & F21::
LShift & F22::
LShift & F23::
LShift & F24::

LShift & AppsKey::

LShift & LWin::
LShift & RWin::

LShift & PrintScreen::
LShift & CtrlBreak::
LShift & Pause::
LShift & Break::

LShift & Help::
LShift & Sleep::

LShift & Browser_Back::
LShift & Browser_Forward::
LShift & Browser_Refresh::
LShift & Browser_Stop::
LShift & Browser_Search::
LShift & Browser_Favorites::
LShift & Browser_Home::
LShift & Volume_Mute::
LShift & Volume_Down::
LShift & Volume_Up::
LShift & Media_Next::
LShift & Media_Prev::
LShift & Media_Stop::
LShift & Media_Play_Pause::
LShift & Launch_Mail::
LShift & Launch_Media::
LShift & Launch_App1::
LShift & Launch_App2::

LShift & Up::
LShift & Down::
LShift & Left::
LShift & Right::
LShift & Space::
LShift & Enter::

LShift & Numpad0::
LShift & NumpadIns::
LShift & Numpad1::
LShift & NumpadEnd::
LShift & Numpad2::
LShift & NumpadDown::
LShift & Numpad3::
LShift & NumpadPgDn::
LShift & Numpad4::
LShift & NumpadLeft::
LShift & Numpad5::
LShift & NumpadClear::
LShift & Numpad6::
LShift & NumpadRight::
LShift & Numpad7::
LShift & NumpadHome::
LShift & Numpad8::
LShift & NumpadUp::
LShift & Numpad9::
LShift & NumpadPgUp::
LShift & NumpadDot::
LShift & NumpadDel::
LShift & NumpadDiv::
LShift & NumpadMult::
LShift & NumpadAdd::
LShift & NumpadSub::
LShift & NumpadEnter::

LShift & a::
LShift & b::
LShift & c::
LShift & d::
LShift & e::
LShift & f::
LShift & g::
LShift & h::
LShift & i::
LShift & j::
LShift & k::
LShift & l::
LShift & m::
LShift & n::
LShift & o::
LShift & p::
LShift & q::
LShift & r::
LShift & s::
LShift & t::
LShift & u::
LShift & v::
LShift & w::
LShift & x::
LShift & y::
LShift & z::

LShift & 0::
LShift & 1::
LShift & 2::
LShift & 3::
LShift & 4::
LShift & 5::
LShift & 6::
LShift & 7::
LShift & 8::
LShift & 9::

; keyboard specific keys
; TODO (change them according to your keyboard layout)
LShift & š::
LShift & đ::
LShift & č::
LShift & ć::
LShift & ž::
LShift & '::
LShift & +::
LShift & ,::
LShift & .::
LShift & -::
LShift & SC056::    ; <
LShift & SC029::    ; CEDILLA

ResendKey()
return
Back to top
jtuttle



Joined: 06 Nov 2008
Posts: 19

PostPosted: Sun Dec 21, 2008 1:23 am    Post subject: Re: Toddler Keyboard - A variation Reply with quote

bmazic wrote:
What this means in practice is that you can surf the net, watch a movie, read a document, etc. while your dearest human being is banging against the keyboard.


I don't have kids, but I have cats, who like to practice their keyboarding while I'm asleep. This is perfect!
Back to top
View user's profile Send private message
Frankie



Joined: 02 Nov 2008
Posts: 823

PostPosted: Mon Dec 22, 2008 12:43 am    Post subject: Reply with quote

Haha nice one. Ill try this out on my little brother. That windows key can get in the way of his key mashing...
_________________
Click here to join #AHK channel in IRC for general chat and quick help.
Back to top
View user's profile Send private message AIM Address
bqw371



Joined: 26 Nov 2008
Posts: 19

PostPosted: Tue Dec 23, 2008 12:54 am    Post subject: Re: Toddler Keyboard - A variation Reply with quote

bmazic wrote:
It is most useful for tasks that require few and occasional keyboard input.

Boris,

I was prompted about duplicate\non-existent keys & removed them from the script. Thanks for the script, it works great!


Code:

; Toddler Keyboard
; v1.0 19dec2008
;
; AutoHotkey Version: 1.x
; Platform: WinNT/2k/XP
; Author:   Boris Mazic
;
; Script Function:
;   Based on bobbo's Toddler Keyboard script, but with the mind
;   on the parents using the computer, not the kids.
;
;   I have a kid that, like any other kid, feels a strong urge
;   to do whatever his dad is doing. Likewise so when it comes
;   to computers... It is next to impossible to surf the net or
;   watch a movie without him wanting to help a little, after all
;   all these keys are there to be pressed, banged against, popped
;   out, and what not. Are they not?!
;   
;   The idea behind the script is to allow some keyboard control,
;   while at the same time making the keyboard childproof. What
;   this means in practice is that you can surf the net, watch a
;   movie, read a document, etc. while your dearest human being
;   is banging against the keyboard. It is most useful for tasks
;   that require few and occasional keyboard input.
;
;   This is accomplished by disabling all keyboard keys and mouse
;   buttons by default, but allowing the keyboard and mouse input
;   by using a specific keyboard modifier. By default this is the
;   left shift key (you can change this relatively easy - just
;   search for TODO within this script and follow the instructions).
;
;   So, whenever you need a certain key combination, just add left
;   shift to it. For example, to paste a clipboard content, instead
;   of pressing Ctrl+V (which does nothing), press LShift+Ctrl+V. To
;   use mouse buttons, hold the left shift key down while pressing a
;   mouse button.
;
;   If you need a key combination that contains shift key, use right
;   shift key to do it: e.g. LShift+Ctrl+RShift+Space would produce
;   Ctrl+Shift+Space key combination.
;
;   You can suspend the script action by pressing LShift+Ctrl+Alt+S,
;   which will restore full keyboard access. Press Ctrl+Alt+S to enable
;   the script again.
;
;-------------------------------------------------

#NoEnv ;
SendMode Input ;


; TODO
; If you want a different keyboard modifier, make sure you change it here
; and all references to it in the section 'KEYS ALLOWED' below.
prefix := "LShift & "


ResendKey()
{
    global prefix
    key := A_ThisHotkey
    mod := (GetKeyState("RShift", "P") ? "+" : "")
    mod .= (GetKeyState("Alt", "P") ? "!" : "")
    mod .= (GetKeyState("Control", "P") ? "^" : "")
    mod .= (GetKeyState("LWin", "P") || GetKeyState("RWin", "P") ? "#" : "")
    key := RegExReplace(key, "^" . prefix . "\s*")
    hotkey := "*" . key

    Hotkey, %hotkey%, Off
    Send, %mod%{%key%}
    Hotkey, %hotkey%, On
}


;key list found at: http://www.autohotkey.com/docs/KeyList.htm


^!s::Suspend  ; Assign the toggle-suspend function to a hotkey.


;-------------------------------------------------
;KEYS NOT ALLOWED:
;-------------------------------------------------

; Mouse buttons

*LButton::
*RButton::
*MButton::

*WheelDown::
*WheelUp::

*XButton1::
*XButton2::


; Keyboard keys

*Tab::
*Escape::
*Backspace::

*Delete::
*Insert::
*Home::
*End::
*PgUp::
*PgDn::

*ScrollLock::
*CapsLock::
*NumLock::

*F1::
*F2::
*F3::
*F4::
*F5::
*F6::
*F7::
*F8::
*F9::
*F10::
*F11::
*F12::
*F13::
*F14::
*F15::
*F16::
*F17::
*F18::
*F19::
*F20::
*F21::
*F22::
*F23::
*F24::

*AppsKey::

*LWin::
*RWin::

*LControl::
*RControl::
*LShift::
*RShift::
*LAlt::
*RAlt::

*PrintScreen::
*CtrlBreak::
*Pause::
*Break::

*Help::
*Sleep::

*Browser_Back::
*Browser_Forward::
*Browser_Refresh::
*Browser_Stop::
*Browser_Search::
*Browser_Favorites::
*Browser_Home::
*Volume_Mute::
*Volume_Down::
*Volume_Up::
*Media_Next::
*Media_Prev::
*Media_Stop::
*Media_Play_Pause::
*Launch_Mail::
*Launch_Media::
*Launch_App1::
*Launch_App2::

*Up::
*Down::
*Left::
*Right::
*Space::
*Enter::

*Numpad0::
*NumpadIns::
*Numpad1::
*NumpadEnd::
*Numpad2::
*NumpadDown::
*Numpad3::
*NumpadPgDn::
*Numpad4::
*NumpadLeft::
*Numpad5::
*NumpadClear::
*Numpad6::
*NumpadRight::
*Numpad7::
*NumpadHome::
*Numpad8::
*NumpadUp:
*Numpad9::
*NumpadPgUp::
*NumpadDot::
*NumpadDel::
*NumpadDiv::
*NumpadMult::
*NumpadAdd::
*NumpadSub::
*NumpadEnter::

*a::
*b::
*c::
*d::
*e::
*f::
*g::
*h::
*i::
*j::
*k::
*l::
*m::
*n::
*o::
*p::
*q::
*r::
*s::
*t::
*u::
*v::
*w::
*x::
*y::
*z::

*0::
*1::
*2::
*3::
*4::
*5::
*6::
*7::
*8::
*9::

; keyboard specific keys
; TODO (change them according to your keyboard layout)
*š::
*đ::
*č::
*ć::
*ž::
*'::
*+::
*,::
*.::
*-::
*SC056::    ; <
*SC029::    ; CEDILLA

;not an allowed key, so do nothing
return

;-------------------------------------------------
;KEYS ALLOWED:
;-------------------------------------------------

; Mouse buttons

LShift & LButton::
LShift & RButton::
LShift & MButton::

LShift & WheelDown::
LShift & WheelUp::

LShift & XButton1::
LShift & XButton2::


; Keyboard keys

LShift & Tab::
LShift & Escape::
LShift & Backspace::

LShift & Delete::
LShift & Insert::
LShift & Home::
LShift & End::
LShift & PgUp::
LShift & PgDn::

LShift & ScrollLock::
LShift & CapsLock::
LShift & NumLock::

LShift & F1::
LShift & F2::
LShift & F3::
LShift & F4::
LShift & F5::
LShift & F6::
LShift & F7::
LShift & F8::
LShift & F9::
LShift & F10::
LShift & F11::
LShift & F12::
LShift & F13::
LShift & F14::
LShift & F15::
LShift & F16::
LShift & F17::
LShift & F18::
LShift & F19::
LShift & F20::
LShift & F21::
LShift & F22::
LShift & F23::
LShift & F24::

LShift & AppsKey::

LShift & LWin::
LShift & RWin::

LShift & PrintScreen::
LShift & CtrlBreak::
LShift & Pause::
LShift & Break::

LShift & Help::
LShift & Sleep::

LShift & Browser_Back::
LShift & Browser_Forward::
LShift & Browser_Refresh::
LShift & Browser_Stop::
LShift & Browser_Search::
LShift & Browser_Favorites::
LShift & Browser_Home::
LShift & Volume_Mute::
LShift & Volume_Down::
LShift & Volume_Up::
LShift & Media_Next::
LShift & Media_Prev::
LShift & Media_Stop::
LShift & Media_Play_Pause::
LShift & Launch_Mail::
LShift & Launch_Media::
LShift & Launch_App1::
LShift & Launch_App2::

LShift & Up::
LShift & Down::
LShift & Left::
LShift & Right::
LShift & Space::
LShift & Enter::

LShift & Numpad0::
LShift & NumpadIns::
LShift & Numpad1::
LShift & NumpadEnd::
LShift & Numpad2::
LShift & NumpadDown::
LShift & Numpad3::
LShift & NumpadPgDn::
LShift & Numpad4::
LShift & NumpadLeft::
LShift & Numpad5::
LShift & NumpadClear::
LShift & Numpad6::
LShift & NumpadRight::
LShift & Numpad7::
LShift & NumpadHome::
LShift & Numpad8::
LShift & NumpadUp::
LShift & Numpad9::
LShift & NumpadPgUp::
LShift & NumpadDot::
LShift & NumpadDel::
LShift & NumpadDiv::
LShift & NumpadMult::
LShift & NumpadAdd::
LShift & NumpadSub::
LShift & NumpadEnter::

LShift & a::
LShift & b::
LShift & c::
LShift & d::
LShift & e::
LShift & f::
LShift & g::
LShift & h::
LShift & i::
LShift & j::
LShift & k::
LShift & l::
LShift & m::
LShift & n::
LShift & o::
LShift & p::
LShift & q::
LShift & r::
LShift & s::
LShift & t::
LShift & u::
LShift & v::
LShift & w::
LShift & x::
LShift & y::
LShift & z::

LShift & 0::
LShift & 1::
LShift & 2::
LShift & 3::
LShift & 4::
LShift & 5::
LShift & 6::
LShift & 7::
LShift & 8::
LShift & 9::

; keyboard specific keys
; TODO (change them according to your keyboard layout)
LShift & š::
LShift & đ::
LShift & č::
LShift & ć::
LShift & ž::
LShift & '::
LShift & +::
LShift & ,::
LShift & .::
LShift & -::
LShift & SC056::    ; <
LShift & SC029::    ; CEDILLA

ResendKey()
return
Back to top
View user's profile Send private message
jtuttle



Joined: 06 Nov 2008
Posts: 19

PostPosted: Fri Jan 02, 2009 6:43 pm    Post subject: Reply with quote

This does not block the scrollpad on my laptop. Not a big deal, just an fyi Very Happy
Back to top
View user's profile Send private message
PlaceboZA
Guest





PostPosted: Wed Apr 29, 2009 10:27 pm    Post subject: Toddler Friend Reply with quote

Great stuff, guys. Thanks!

I now took it a step further and rewritten it all to combine features from all the above versions, and have a UI to work with.

I called it Toddler Friend and it's in version 0.9b (beta, not tested enough)

Features:
- Override key (as before - defaulted it to NumLock but easy to change)
- Convert blocked keys to space (for 'hit any key' games)
- Ability to allow mouse, alphanumerics, arrows independently
- Prevent key repeat (not working quite right though)
- Hotkeys to toggle all features
- UI to modify the features in a user friendly way
- Easy to change settings

Code:
; Toddler Friend v 0.9b
; v1.0 48.02 April 09
;
; AutoHotkey Version: 1.x (fails with version 1.0.44.07)
; Platform: WinNT/2k/XP
; Author:   Greg De Haas (PlaceboZA, www.grelly.com)
;
; Script Function:
; Allows you to block keyboard and mouse functions selectively, to prevent your adorable wadget
; from doing something silly (like closing the window or rebooting)
; There is also an override key of NumLock (easily changeable) which will allow you to use the keyboard normally while holding
; In addition, you can force all blocked keys to produce a space (Nice for games where 'hit any key' applies)
; And that's not all... you get key repeat prevention as well (although this isn't quite right as at time of writing)
; Feel free to change settings below
;
; Things you might like to change:
; - The override key & startup settings. Just change it in the Public Settings section below
; - If you, for example, want spacebar hotkey to be considered as part of the alpha-numeric keys,
;   then simply move it into the alpha-numeric section
; - I don't convert mouse buttons to spaces when using the 'replace keys with space' option, because my daughter hits the touchpad too easily
; - Compile to exe, give it an icon, remove tray icon, etc
;
; TODO:
; - When enabled & with allow mouse buttons, you still can't drag windows. Not sure why.
;   - The prevention of repeat keys doesn't quite work right.. seems to still allow for a single follup repeat
; - Left Control and Shift keys couldn't be blocked because they interfere with the global shortcuts
; - Some laptops' touchpad scrolls aren't blocked apparently
;   - Block Ctrl-Alt-Del ? Debatable.. and not really necessary IMO
;
; Credits:
; Boris Mazic and bobbo for the original idea of the Toddler Keyboard scripts

#NoEnv ;
SendMode Input ;

;----------- Public Settings (Change as needed) -------------------
OverrideKey := "NumLock"  ;Remember to comment it out from the hotkeys below (don't block it) and uncomment the one that was used previously
ShowSettingsOnStart = true
StartEnabled := false
StartWithAllowAlphaNumeric := false
StartWithAllowArrows := false
StartWithConvertToSpace := false
StartWithPreventRepeats := true
AllowConvertMouseButtonsToSpace := false   ;If false, then only keyboard actions result in space, if Convert To Space is on

;----------- Private Settings -------------------------------------
Version := "0.9b"

;----------- Initial Values ---------------------------------------
m_enabled := (StartEnabled) ? 1 : 0
m_allowAlphanumerics := (StartWithAllowAlphaNumeric) ? 1 : 0
m_allowMouse := (StartWithAllowMouse) ? 1 : 0
m_allowArrows := (StartWithAllowArrows) ? 1 : 0
m_replaceWithSpace := (StartWithConvertToSpace) ? 1 : 0
m_preventRepeats := (StartWithPreventRepeats) ? 1 : 0
m_hintState := 0   ;0=no hint, 1=hint displayed, 2=busy building

;Suspend if needed
if !m_enabled
      Suspend On

;Set up menu   
Menu, TRAY, NoStandard
Menu, TRAY, Add, Show Settings..., OnShowSettings
Menu, TRAY, Add, Exit, OnExitApp
Menu, TRAY, Default, Show Settings...

if ShowSettingsOnStart
   DisplaySettings()
      
return

ResendKeyEx(key, prevKey, timeSince, noRepeat)
{       
   if (!noRepeat or !CheckIfRepeat(key, prevKey, timeSince))
      ResendKey(key)
}

CheckIfRepeat(key, prevKey, timeSince)
{
   return (key = prevKey and timeSince < 150) ? true : false
}

ResendKey(key)
{
      global OverrideKey
      
      mod := (GetKeyState("RShift", "P") ? "+" : "")
      mod .= (GetKeyState("Alt", "P") ? "!" : "")
      mod .= (GetKeyState("Control", "P") ? "^" : "")
      mod .= (GetKeyState("LWin", "P") || GetKeyState("RWin", "P") ? "#" : "")
      


      key := RegExReplace(key, "^" . OverrideKey . "\s+\&\s*")    ;Remove override key if necessary
      key := RegExReplace(key, "^\*")
      
      ;FileAppend, %mod% + %key%`n, C:\keys.txt
               
      ;Resend key
      hotkey := "*" . key   
      Hotkey, %hotkey%, Off, UseErrorLevel
      Send, %mod%{%key%}
      Hotkey, %hotkey%, On, UseErrorLevel
}

CheckForOverride()
{
   global OverrideKey
   state := GetKeyState(OverrideKey, "P")
      return state
}

DisplaySettings()
{
   global Version
   global m_allowAlphanumerics
   global m_replaceWithSpace
   global m_allowMouse
   global m_enabled
   global m_allowArrows
   global m_preventRepeats
   global OverrideKey 
   grayed := (m_enabled = 0) ? "Disabled" : ""
   note := "Global Shortcuts: " . OverrideKey . " + Ctrl + Shift + [Option]"
   
   Gui 8: Default
   Gui, Destroy 
   Gui, +AlwaysOnTop +LastFound +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
   Gui, Color, EEF2FF
   Gui, Font, s8, Tahoma
   Gui, Add, CheckBox, x12 y7 Autosize h20 vm_enabled Checked%m_enabled% gOnEnable, [E]nable Toddler Control
   Gui, Add, CheckBox, x12 y27 Autosize h20 %grayed% Checked%m_replaceWithSpace% vm_replaceWithSpace, [R]eplace blocked keys with space
   Gui, Add, CheckBox, x12 y47 Autosize h20 %grayed% Checked%m_preventRepeats% vm_preventRepeats, [P]revent held keys from repeating
   Gui, Add, GroupBox, x12 y70 w300 h90, Block everything except...
   Gui, Add, CheckBox, x22 y87 Autosize h20 %grayed% Checked%m_allowAlphanumerics% vm_allowAlphanumerics, [A]lpha-numeric keys
   Gui, Add, CheckBox, x22 y107  Autosize h20 %grayed% Checked%m_allowMouse% vm_allowMouse, [M]ouse buttons
   Gui, Add, CheckBox, x22 y127 Autosize h20 %grayed% Checked%m_allowArrows% vm_allowArrows, [C]ursor/arrow keys
   Gui, Add, Text, x15 y165 w300 h20, %note%
   Gui, Add, Button, x162 y192 w70 h20 gOnOK Default, &OK
   Gui, Add, Button, x242 y192 w70 h20 gOnCancel, &Cancel 
   Gui, Show, Center h196 Autosize, [T]oddler Friend v%Version%, PlaceboZA (grelly.com)   ; NoActivate avoids deactivating the currently active window.   
   Gui 1: Default
   return
      
8GuiEscape:
   Gui 8: Cancel
   return
      
OnEnable:
   Gui 8: Default
   GuiControlGet, state, , m_enabled
   enable := (state = 1) ? "Enable" : "Disable"
   GuiControl, %enable%, m_replaceWithSpace
   GuiControl, %enable%, m_preventRepeats
   GuiControl, %enable%, m_allowAlphanumerics
   GuiControl, %enable%, m_allowMouse
   GuiControl, %enable%, m_allowArrows
   Gui 1: Default
   return
   
OnOK:
   Gui 8: Submit
   if m_enabled
      Suspend Off
   else
      Suspend On
   return
   
OnCancel:
   Gui 8: Cancel
   return
}

DisplayQuickHint(HintText, Delay)              ;Gui #9 is the hint
{
   ;Use HintState and close window if still displaying
   global HintState
   if HintState = 1
      Gui, 9: Destroy ;Close it
      
   ;Init
   HintState = 2
   
   ;Set Gui
   Gui 9: +AlwaysOnTop   +LastFound +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
   Gui 9: Color, EEF2FF
   Gui 9: Font, s8 bold, Verdana
   Gui 9: Add, Text, cBlack, %HintText%     
   Gui 9: -Caption   +Border ; Remove the title bar and window borders.
   Gui 9: Show, x2   y2 NoActivate AutoSize  ; NoActivate avoids deactivating the currently active window.
         
   HintState = 1
   SetTimer, CloseHintLabel, %Delay%
   return   
      
CloseHintLabel:
   SetTimer, CloseHintLabel, Off
   if HintState = 1
      Gui, 9: Destroy ;Close it
   return
}

ToggleEnabled()
{
   global m_enabled
   m_enabled := (m_enabled = 1) ? 0 : 1
   if m_enabled = 1
      Suspend Off
   else
      Suspend On     
   DisplayQuickHint("Toddler Friend: " . ((m_enabled = 1) ? "Enabled" : "Disabled"), 1500)
}

ToggleSpaceConvert()
{
   global m_replaceWithSpace
   m_replaceWithSpace := (m_replaceWithSpace = 1) ? 0 : 1
   DisplayQuickHint("Toddler Friend: Blocked keys" . ((m_replaceWithSpace = 1) ? " will be " : " are no longer ") . "converted to a space", 1500)
}

ToggleAllowMouse()
{
   global m_allowMouse
   m_allowMouse := (m_allowMouse = 1) ? 0 : 1
   DisplayQuickHint("Toddler Friend: Mouse buttons" . ((m_allowMouse = 1) ? " will be allowed" : " will be blocked"), 1500)
}

ToggleAllowArrows()
{
   global m_allowArrows
   m_allowArrows := (m_allowArrows = 1) ? 0 : 1
   DisplayQuickHint("Toddler Friend: Cursor/arrow keys" . ((m_allowArrows = 1) ? " will be allowed" : " will be blocked"), 1500)
}

ToggleAllowAlphanumerics()
{
   global m_allowAlphanumerics
   m_allowAlphanumerics := (m_allowAlphanumerics = 1) ? 0 : 1
   DisplayQuickHint("Toddler Friend: Alpha-numeric keys" . ((m_allowAlphanumerics = 1) ? " will be allowed" : " will be blocked"), 1500)
}

TogglePreventRepeats()
{
   global m_preventRepeats
   m_preventRepeats := (m_preventRepeats = 1) ? 0 : 1
   DisplayQuickHint("Toddler Friend: Held keys will" . ((m_preventRepeats = 1) ? " cause a single keypress" : " will repeat the keypress "), 1500)
}

OnExitApp:    ;Used by tray menu
   ExitApp
   return

OnShowSettings: ;Used by tray menu
   DisplaySettings()
   return

; Global system shortcuts
^+e:: ;Enable/Disable
      Suspend, Permit   ;Allow when suspended
      if CheckForOverride()
         ToggleEnabled()
      return   
   
^+t:: ;Display Settings
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      DisplaySettings()
   return
   
^+r:: ;Replace spaces
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      ToggleSpaceConvert()
   return

^+p:: ;Prevent repeats of held keys
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      TogglePreventRepeats()
   return
   
^+m:: ;Allow mouse
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      ToggleAllowMouse()
   return
   
^+c:: ;Allow cursor
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      ToggleAllowArrows()
   return
   
^+a:: ;Allow alphanumerics
   Suspend, Permit   ;Allow when suspended
   if CheckForOverride()
      ToggleAllowAlphanumerics()
   return

; Alpha-numerics
*a::
*b::
*c::
*d::
*e::
*f::
*g::
*h::
*i::
*j::
*k::
*l::
*m::
*n::
*o::
*p::
*q::
*r::
*s::
*t::
*u::
*v::
*w::
*x::
*y::
*z::

*0::
*1::
*2::
*3::
*4::
*5::
*6::
*7::
*8::
*9::
   if CheckForOverride() or m_allowAlphanumerics = 1
      ResendKeyEx(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey, (m_preventRepeats = 1) ? true : false)
   else if (m_replaceWithSpace = 1 and (m_preventRepeats = 0 or !CheckIfRepeat(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey)))
      Send, {Space}
   return
   
; Mouse buttons
*LButton::
*RButton::
*MButton::

*WheelDown::
*WheelUp::

*XButton1::
*XButton2::
   if CheckForOverride() or m_allowMouse = 1
      ResendKeyEx(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey, (m_preventRepeats = 1) ? true : false)
   else if (m_replaceWithSpace = 1 and AllowConvertMouseButtonsToSpace)
      Send, {Space}
   return

; Arrows
*Up::
*Down::
*Left::
*Right::
   if CheckForOverride() or m_allowArrows = 1
      ResendKeyEx(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey, (m_preventRepeats = 1) ? true : false)
   else if (m_replaceWithSpace = 1  and (m_preventRepeats = 0 or !CheckIfRepeat(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey)))
      Send, {Space}
   return
      
; Other keys (starting with ones you might want to include above)
*Space::
*Enter::
*Tab::
*Escape::
*Backspace::
   
*Numpad0::
*NumpadIns::
*Numpad1::
*NumpadEnd::
*Numpad2::
*NumpadDown::
*Numpad3::
*NumpadPgDn::
*Numpad4::
*NumpadLeft::
*Numpad5::
*NumpadClear::
*Numpad6::
*NumpadRight::
*Numpad7::
*NumpadHome::
*Numpad8::
*NumpadUp:
*Numpad9::
*NumpadPgUp::
*NumpadDot::
*NumpadDel::
*NumpadDiv::
*NumpadMult::
*NumpadAdd::
*NumpadSub::
*NumpadEnter::

*Delete::
*Insert::
*Home::
*End::
*PgUp::
*PgDn::

*ScrollLock::   
*CapsLock::
;*NumLock::     ;This interferes with global shortcuts and overrides

*F1::
*F2::
*F3::
*F4::
*F5::
*F6::
*F7::
*F8::
*F9::
*F10::
*F11::
*F12::
*F13::
*F14::
*F15::
*F16::
*F17::
*F18::
*F19::
*F20::
*F21::
*F22::
*F23::
*F24::

*AppsKey::

*LWin::
*RWin::

;*LControl::  ;These interfere with global shortcuts
*RControl::
;*LShift::    ;These interfere with global shortcuts
*RShift::
*LAlt::
*RAlt::

*PrintScreen::
*CtrlBreak::
*Pause::
*Break::

*Help::
*Sleep::

*Browser_Back::
*Browser_Forward::
*Browser_Refresh::
*Browser_Stop::
*Browser_Search::
*Browser_Favorites::
*Browser_Home::
*Volume_Mute::
*Volume_Down::
*Volume_Up::
*Media_Next::
*Media_Prev::
*Media_Stop::
*Media_Play_Pause::
*Launch_Mail::
*Launch_Media::
*Launch_App1::
*Launch_App2:: 
   if CheckForOverride()
      ResendKeyEx(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey, (m_preventRepeats = 1) ? true : false)
   else if (m_replaceWithSpace = 1  and (m_preventRepeats = 0 or !CheckIfRepeat(A_ThisHotkey, A_PriorHotkey, A_TimeSincePriorHotkey)))
      Send, {Space}
   return
Back to top
PlaceboZA



Joined: 30 Apr 2009
Posts: 1

PostPosted: Sat May 02, 2009 3:32 pm    Post subject: Reply with quote

Be careful to make sure of your override key before running the script!
If you're using a laptop where e.g. NumLock is accessed with a function key, make sure you change the key first.
Otherwise you'll be rebooting Smile
Back to top
View user's profile Send private message
Hannibal_32



Joined: 15 May 2009
Posts: 8
Location: Tulsa, OK

PostPosted: Fri May 29, 2009 10:53 pm    Post subject: Reply with quote

Instead of disabling all the keys, I believe I will search for a bunch of funny .wav sounds and just assigning all of the keys out.. OR, I guess I could make it a learning tool and find .wav sounds of the letters and numbers. Lots of applications..

NICE SCRIPT!

H
Back to top
View user's profile Send private message
DreymaR



Joined: 24 May 2009
Posts: 39
Location: Bærum, Norway

PostPosted: Sat May 30, 2009 1:27 am    Post subject: Reply with quote

PlaceboZA wrote:
Be careful to make sure of your override key before running the script!
If you're using a laptop where e.g. NumLock is accessed with a function key, make sure you change the key first.
Otherwise you'll be rebooting Smile


Have you actually tried that out? Because as far as I know, the 'Fn' keys are usually hardware-implemented and won't be blocked by the script. Thus, the NumLock key with or without having to activate Fn first should be sent to the system as that key only, regardless of the script.
_________________
Better burden you cannot carry than man-wisdom much -- Hávamál
Back to top
View user's profile Send private message
Beholder
Guest





PostPosted: Sun May 31, 2009 9:41 pm    Post subject: Reply with quote

Guys, I found this thread too late, didn't occur to me to search for "toddler". I searched only for "block keyboard", "lock keyboard" and of course "block input".

Here is a solution that I am most pleased with:

I found the "KidKeyLock" application (KKL) very useful. Setup the program to lock mouse clicks, wheel and also whole keyboard.
Then autohotkey can be used to run the program via keyboard shortcut.
Just type "kklquit" (or the password you set up on your own) to end the keyboard/mouse blocking and quit the KKL.

EASY!

Get the KKL app here: http://www.100dof.com/kidkeylock.html

The only thing this does not block is the CTRL+ALT+Del combination, mouse movement and a few keys on my Gyration Remote.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group