Jump to content

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

trying to emulate numpad with capslock toggle



  • Please log in to reply
6 replies to this topic
jinchoung
  • Members
  • 4 posts
  • Last active: Dec 14 2014 10:10 AM
  • Joined: 14 Dec 2014

hi,

 

i'm trying to emulate a numpad on my new tenkeyless keyboard.  i've got most of it working now but i'd like for the numpad emulation to start in an off state, to be toggled on when i hit the CAPSLOCK key.  also, i would really like the capslock key to illuminate when the numpad is being illuminated... right now, on or off, the light does not come on.

 

here is the code i'm using:

 

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
 
;======================================
;NumPad-CODE
;remapping "normal" number keys to make them 
;behave like numpad numbers
 
0::Numpad0
j::Numpad1
k::Numpad2
l::Numpad3
u::Numpad4
i::Numpad5
o::Numpad6
7::Numpad7
8::Numpad8
9::Numpad9
SC034::NumpadDot
/::NumpadDiv
=::NumpadAdd
-::NumpadSub
`;::NumpadMult
\::NumLock
 
;using the "CapsLock" to turn on/off remapping code
CapsLock::
Suspend,Toggle
SetCapsLockState, % (State:=!State) ? "Off" : "On"
return
;===================================
 
 
thanks much for the help.
 
jin
 


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Here's what I use for my greek (and a bit more) keyboard (which one day soon I'll get around to actually finishing up) toggled by capslocks:

 

#If GetKeyState("CapsLock","T")
o::Send {ASC 0176} ; used to be ASC 167 but Word liked to have that as an underlined circle...
+/::Send {ASC 168}
+1::Send {ASC 173}
a::Send {ASC 224}
^a::Send {ASC 143}
b::Send {ASC 225}
c::Send {U+03B3}
p::Send {ASC 227}
e::Send {U+03B5} ; This is epsilon
s::Send {ASC 228} ; capital sigma
^s::Send {ASC 229} ; lowercase sigma is not used quite enough
m::Send {ASC 230}
t::Send {ASC 231}
i::Send {ASC 232}
h::Send {U+03B8} ; theta
w::Send {ASC 234}
^d::Send {ASC 235}
d::Send {U+0394} ;;;;
+=::Send {ASC 241}
+.::Send {ASC 242}
+,::Send {ASC 243}
+8::Send {ASC 0134}
+7::Send {ASC 0135}
^8::Send {U+221E}
2::Send {ASC 253}

 

So you should be able to this to your needs. Basically, just the #If GetKeyState("CapsLock","T") should be what you want above the hotkeys to make them context-sensitive. Your CapsLock key/hardware light will be illuminated when these hotkeys are active that way.



jinchoung
  • Members
  • 4 posts
  • Last active: Dec 14 2014 10:10 AM
  • Joined: 14 Dec 2014

hi,

 

thanks much for the help.

 

but when i try to execute your code, i get an error for #If GetKeyState("CapsLock","T")

 

it says that the line does not contain a recognizable action.

 

jin



Masonjar13
  • Members
  • 1517 posts
  • Last active:
  • Joined: 16 Sep 2012

Use this version of AHK: ahkscript.org/download/


OS: Windows 7 Ultimate / Windows 8.1 Pro | Editor: Notepad++


T_Lube
  • Members
  • 640 posts
  • Last active: Sep 09 2016 02:19 AM
  • Joined: 16 Oct 2014

use a comm on the #if Like "#If, GetKeyState("CapsLock", "T"). " Maybe that won't help but it is the syntax in the help file.



jinchoung
  • Members
  • 4 posts
  • Last active: Dec 14 2014 10:10 AM
  • Joined: 14 Dec 2014

thanks everyone!

 

Masonjar13, the version that you specified resolved the error.  thanks very much for the assist.

 

jin



jinchoung
  • Members
  • 4 posts
  • Last active: Dec 14 2014 10:10 AM
  • Joined: 14 Dec 2014
✓  Best Answer

thanks everyone!

 

Masonjar13, the version that you specified resolved the error.  thanks very much for the assist.

 

jin

 

FYI, here is the code for my numpad emulation:

 

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
 
;======================================
;NumPad-CODE
;remapping "normal" number keys to make them 
;behave like numpad numbers
 
#If GetKeyState("CapsLock","T")
 
0::Numpad0
j::Numpad1
k::Numpad2
l::Numpad3
u::Numpad4
i::Numpad5
o::Numpad6
7::Numpad7
8::Numpad8
9::Numpad9
SC034::NumpadDot
/::NumpadDiv
=::NumpadAdd
-::NumpadSub
`;::NumpadMult
\::NumLock