Jump to content

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

Disable the windows key


  • Please log in to reply
8 replies to this topic
FSahk
  • Members
  • 4 posts
  • Last active: Apr 25 2008 10:40 PM
  • Joined: 04 Feb 2008
Do you play computer games and minimize in the middle of game play because of hitting the windows key or need to disable the windows key for other reasons. Here is a small example of how to disable the windows key. As always you should be sure to review the code first before copying and pasting. This code edits the windows registry


#SingleInstance force
Gui, Add, Button, x96 y105 w100 h30, Apply
Gui, Add, DropDownList, vWinKeyVar x56 y45 w190 h110,Disable Left Winkey|Disable Right Winkey|Disable Both Winkey||Restore All Winkeys  
Gui, Add, Text, x86 y5 w150 h20, Disable the windows key  
Gui, Show, x270 y110 h146 w294, Disable the windows key
Return

GuiClose:
ExitApp

ButtonApply:
gui,submit,nohide
If WinKeyVar = Disable Left Winkey
goto, DisableLeftWinkey
Else
If WinKeyVar = Disable Right Winkey
goto, DisableRightWinkey
Else
If WinKeyVar = Disable Both Winkey
goto, DisableBothWinkey
Else
If WinKeyVar = Restore All Winkeys
goto, RestoreallWinkey
Else
return
return

DisableLeftWinkey:
RegDelete, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout, Scancode Map
sleep, 1000
RegWrite,  REG_BINARY, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout, Scancode Map, 00000000000000000200000000005BE000000000
MsgBox, 292, Left Windows key, Left Windows key disabled. The computer needs to be restarted. Will you like to restart now?
IfmsgBox, Yes
goto,Restartpc
IfmsgBox, No
Return
Return


DisableRightWinkey:
RegDelete, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout, Scancode Map
sleep, 1000
RegWrite,  REG_BINARY, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout,Scancode Map,00000000000000000200000000005CE000000000
MsgBox, 292, Right Windows key, Right Windows key disabled. The computer needs to be restarted. Will you like to restart now?
IfmsgBox, Yes
goto,Restartpc
IfmsgBox, No
Return
Return


DisableBothWinkey:
RegDelete, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout, Scancode Map
sleep, 1000
RegWrite,  REG_BINARY, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout,Scancode Map,00000000000000000300000000005BE000005CE000000000
MsgBox, 292, Both Windows key, Both Windows key disabled. The computer needs to be restarted. Will you like to restart now?
IfmsgBox, Yes
goto,Restartpc
IfmsgBox, No
Return
Return


RestoreallWinkey:
RegDelete, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout, Scancode Map
sleep, 1000
RegWrite,  REG_BINARY, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Keyboard Layout,Scancode Map,
MsgBox, 292,[Restored Both Windows key, Both Windows key Restored. The computer needs to be restarted. Will you like to restart now?
IfmsgBox, Yes
goto,Restartpc
IfmsgBox, No
Return
Return

Restartpc:
MsgBox, 36,Restart Computer,Will you like to restart the computer now?
IfMsgBox, Yes
{
 ShutDown,2    ;Restarts Computer or "ShutDown,0" to logoff
 exitapp
}
IfMsgBox, No
{ 
 exitapp
}

Return

If you are looking for free pre-made scripts to use with a little modification for your program or scripts, check out my website at:
http://freescriptsahk.googlepages.com/

ph34r
  • Guests
  • Last active:
  • Joined: --
Rather than messing with the registry and restarting your computer, might I suggest just doing this?

#SingleInstance force
Gui, Add, Button, x96 y105 w100 h30, Apply
Gui, Add, DropDownList, vWinKeyVar x56 y45 w190 h110,Disable Left Winkey|Disable Right Winkey|Disable Both Winkey||Restore All Winkeys 
Gui, Add, Text, x86 y5 w150 h20, Disable the windows key 
Gui, Show, x270 y110 h146 w294, Disable the windows key
Return

GuiClose:
ExitApp

ButtonApply:
gui,submit,nohide
If WinKeyVar = Disable Left Winkey
goto, DisableLeftWinkey
Else
If WinKeyVar = Disable Right Winkey
goto, DisableRightWinkey
Else
If WinKeyVar = Disable Both Winkey
goto, DisableBothWinkey
Else
If WinKeyVar = Restore All Winkeys
goto, RestoreallWinkey
Else
return
return

DisableLeftWinkey:
Hotkey, LWin, Blank, On
Return

DisableRightWinkey:
Hotkey, RWin, Blank, On
Return

DisableBothWinkey:
Hotkey, LWin, Blank, On
Hotkey, RWin, Blank, On
Return

RestoreallWinkey:
Hotkey, LWin, Blank, Off
Hotkey, RWin, Blank, Off
Return

Blank:
Return


Cristi®
  • Members
  • 45 posts
  • Last active: Feb 13 2018 11:57 PM
  • Joined: 29 Nov 2007
or simple do this
LWin::
RWin::
#::

Posted Image

TxT
  • Guests
  • Last active:
  • Joined: --
I have laptop and i dont have right windows button, so if you guys can help me make button for me or like chance it.

rainforest1155
  • Members
  • 3 posts
  • Last active: Apr 08 2010 11:13 PM
  • Joined: 02 Apr 2010
Is it possible to just disable the win key if no key combo, like winkey+r is pressed? So just prevent hitting winkey alone and then getting the start button to pop up.
WinKey Killer worked for me in the past, but it doesn't seem to work on Windows 7 64bit anymore.

Basically I would like to be able to use winkey shortcuts, just not the winkey on its own.

Thanks for any suggestions.

Sebastian

uogpjf
  • Members
  • 2 posts
  • Last active: Apr 05 2010 03:28 PM
  • Joined: 05 Apr 2010
Several months ago, I researched this topic (disable LWin with no modifier, but allow LWin+e and etc.), and found no solution that worked for me at the time. BUT I just now searched, and found the answer:
http://www.autohotke...ic.php?p=345326 ( 2010 Mar 18.) Yay! 8)

~LWin Up:: Return

(similarly for the right one - RWin), but personally, I have no problem with that one.)
--
/PJF

P.S. I recommend this one be put in the FAQ, with as many keywords as you can think of.

rainforest1155
  • Members
  • 3 posts
  • Last active: Apr 08 2010 11:13 PM
  • Joined: 02 Apr 2010

Several months ago, I researched this topic (disable LWin with no modifier, but allow LWin+e and etc.), and found no solution that worked for me at the time. BUT I just now searched, and found the answer:
http://www.autohotke...ic.php?p=345326 ( 2010 Mar 18.) Yay! 8)

Awesome, thanks for replying here!

Sebastian

qwertyspace
  • Members
  • 16 posts
  • Last active: Jan 12 2016 06:23 PM
  • Joined: 15 Jan 2014

How would I be able to change this script to disable the LWin key by a hotkey?

Would this work?

!z::
  ~LWin Up:: Return


qwertyspace
  • Members
  • 16 posts
  • Last active: Jan 12 2016 06:23 PM
  • Joined: 15 Jan 2014

How would I be able to change this script to disable the LWin key by a hotkey?

Would this work?

!z::
  ~LWin Up:: Return

EDIT:  No it does not work.  The windows key remains permanently disabled.  (I'm not very good at this, as you can probably tell.)