Jump to content

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

On Screen Numeric KeyPad


  • Please log in to reply
22 replies to this topic
Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004
I have spent many hours searching the web for a utility to put an on screen numeric keypad which I could use with Excel on my laptop. In less time than I have spent searching I have been able to do just this using AHK and Smart GUI. I stole the keys from Windows Calculator. I'm sure that the code is very rough, but it does the job for me and maybe others may also find it useful.

Revised 1st Nov. '05

; Generated by SmartGUI Creator 3.1
; Revised 09:30 Tue 01 November 2005
gui +AlwaysOnTop
gui, font, Arial Bold S14
Gui, Add, Button, x5 y5 w36 h29, 7
Gui, Add, Button, x5 y35 w36 h29, 4
Gui, Add, Button, x5 y65 w36 h29, 1
Gui, Add, Button, x5 y95 w36 h29, 0
Gui, Add, Button, x44 y5 w36 h29, 8
Gui, Add, Button, x44 y35 w36 h29, 5
Gui, Add, Button, x44 y65 w36 h29, 2
Gui, Add, Button, x44 y95 w36 h29,
Gui, Add, Button, x83 y5 w36 h29, 9
Gui, Add, Button, x83 y35 w36 h29, 6
Gui, Add, Button, x83 y65 w36 h29, 3
Gui, Add, Button, x83 y95 w36 h29, .
Gui, Add, Button, x122 y5 w36 h29, /
Gui, Add, Button, x122 y35 w36 h29, x
Gui, Add, Button, x122 y65 w36 h29, -
Gui, Add, Button, x122 y95 w36 h29, +
Gui, Add, Button, x5 y125 w75 h30, =
Gui, Add, Button, x83 y125 w75 h30, Enter
Gui, Show, x446 y264 h160 w160, Numeric KeyPad
WinActivate, Numeric KeyPad
return

; SEND KEYS TO EXCEL
Button1:
WinActivate, Microsoft Excel
Send,1
return
Button2:
WinActivate, Microsoft Excel
Send,2
return
Button3:
WinActivate, Microsoft Excel
Send,3
return
Button4:
WinActivate, Microsoft Excel
Send,4
return
Button5:
WinActivate, Microsoft Excel
Send,5
return
Button6:
WinActivate, Microsoft Excel
Send,6
return
Button7:
WinActivate, Microsoft Excel
Send,7
return
Button8:
WinActivate, Microsoft Excel
Send,8
return
Button9:
WinActivate, Microsoft Excel
Send,9
return
Button0:
WinActivate, Microsoft Excel
Send,0
return
Button.:
WinActivate, Microsoft Excel
Send,{NumpadDot}
return
Button/:
WinActivate, Microsoft Excel
Send,{NumpadDiv}
return
Buttonx:
WinActivate, Microsoft Excel
Send,{NumpadMult}
return
Button-:
WinActivate, Microsoft Excel
Send,{NumpadSub}
return
Button+:
WinActivate, Microsoft Excel
Send,{NumPadAdd}
return
Button=:
WinActivate, Microsoft Excel
Send,{=}
return
ButtonEnter:
WinActivate, Microsoft Excel
Send,{enter}
return


GuiClose:
ExitApp

Regards,
Martin O'Neill

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Simple yet effective. Thanks for posting it.

jono
  • Guests
  • Last active:
  • Joined: --
Hi
Can someone post this as an .exe file to download?

Thankyou

A Guest
  • Guests
  • Last active:
  • Joined: --
Use Convert .ahk to .exe shortcut in the AHK shortcut folder. to do that.

Laudrin
  • Members
  • 56 posts
  • Last active: Aug 08 2007 03:17 PM
  • Joined: 20 Oct 2005
Hi Jono,

I strongly encourage you to install AutoHotkey. I personaly can't live anymore without. ;-)

It is quite small, the installation is easy and after installing it, you can right click on the saved script (*.ahk) in your favourite file manager (Windows Explorer, Total Commander or other) an select "Compile Script". After doing that, you'll have your .exe file. It's by all means easier than asking for a executable for each script you'll find useful.

I assume you'll need this function more often after learning the usefulness of AutoHotkey itself, not only of one script. :wink:

Edit: danm, one minute too slow. *g*

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Of course, there are many things you can do to improve this script but one q&d thing to improve usability would be to add a gui "AlwaysOnTop" option as the first line of your script . i.e.

gui +AlwaysOnTop
gui, fon.....
...

This option keeps the window from jumping around. Also, if you add the AOT option, you can get rid of the all of the "WinActivate, Numeric KeyPad" statements but no harm in keeping them.

Thanks for the script. I might find a use for it.

Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004

...... one q&d thing to improve usability would be to add a gui "AlwaysOnTop" option as the first line of your script . i.e.

gui +AlwaysOnTop
.....

Many thanks for the suggestion. I have now put a revised version in the first entry.

Nice to see interest in my feeble efforts.

Martin

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Very nice! However, you can simplify it a bit:
gui +AlwaysOnTop
gui font, Arial Bold S14
Gui Add, Button, x5   y5  w36 h29 gButton, 7
Gui Add, Button, x5   y35 w36 h29 gButton, 4
Gui Add, Button, x5   y65 w36 h29 gButton, 1
Gui Add, Button, x5   y95 w36 h29 gButton, 0
Gui Add, Button, x44  y5  w36 h29 gButton, 8
Gui Add, Button, x44  y35 w36 h29 gButton, 5
Gui Add, Button, x44  y65 w36 h29 gButton, 2
Gui Add, Button, x44  y95 w36 h29 gButton vSPACE
Gui Add, Button, x83  y5  w36 h29 gButton, 9
Gui Add, Button, x83  y35 w36 h29 gButton, 6
Gui Add, Button, x83  y65 w36 h29 gButton, 3
Gui Add, Button, x83  y95 w36 h29 gButton, .
Gui Add, Button, x122 y5  w36 h29 gButton, /
Gui Add, Button, x122 y35 w36 h29 gButton, *
Gui Add, Button, x122 y65 w36 h29 gButton, -
Gui Add, Button, x122 y95 w36 h29 gButton, +
Gui Add, Button, x5  y125 w75 h30 gButton, =
Gui Add, Button, x83 y125 w75 h30 gButton, Enter
Gui Show, x446 y264 h160 w160, Numeric KeyPad
WinActivate Numeric KeyPad
return

; SEND KEYS TO EXCEL
Button:
   WinActivate Microsoft Excel
   Send {%A_GuiControl%}
Return


GuiClose:
ExitApp
Here is an enhanced version. It works in any window: a timer subroutine saves the ID of the active window four times a second, if it is not the keypad. When you click on a keypad button, the last window gets activated and the keypad key is sent to there.
SetTimer GetActiveWindow

gui +AlwaysOnTop
gui font, Arial Bold S14
Gui Add, Button, x5   y5  w36 h29 gButton, 7
Gui Add, Button, x5   y35 w36 h29 gButton, 4
Gui Add, Button, x5   y65 w36 h29 gButton, 1
Gui Add, Button, x5   y95 w36 h29 gButton, 0
Gui Add, Button, x44  y5  w36 h29 gButton, 8
Gui Add, Button, x44  y35 w36 h29 gButton, 5
Gui Add, Button, x44  y65 w36 h29 gButton, 2
Gui Add, Button, x44  y95 w36 h29 gButton vSPACE
Gui Add, Button, x83  y5  w36 h29 gButton, 9
Gui Add, Button, x83  y35 w36 h29 gButton, 6
Gui Add, Button, x83  y65 w36 h29 gButton, 3
Gui Add, Button, x83  y95 w36 h29 gButton, .
Gui Add, Button, x122 y5  w36 h29 gButton, /
Gui Add, Button, x122 y35 w36 h29 gButton, *
Gui Add, Button, x122 y65 w36 h29 gButton, -
Gui Add, Button, x122 y95 w36 h29 gButton, +
Gui Add, Button, x5  y125 w75 h30 gButton, =
Gui Add, Button, x83 y125 w75 h30 gButton, Enter
Gui Show, x446 y264 h160 w160, Key±Pad
WinActivate Key±Pad
WinGet KPID, ID, A
return

; SEND KEYS
Button:
   WinActivate ahk_id %LastID%
   Send {%A_GuiControl%}
Return

GuiClose:
ExitApp

GetActiveWindow:
   WinGet ID, ID, A
   IfNotEqual ID,%KPID%, SetEnv LastID,%ID%
Return


Martin
  • Members
  • 34 posts
  • Last active: Jan 06 2012 02:45 PM
  • Joined: 03 Nov 2004

Very nice! However, you can simplify it a bit:
.................
Here is an enhanced version.


Wow!
I will have to spend a lot of time looking at this next week end as I don't understand a number of things you have done, but I am too busy at work just now.

Many thanks,
Martin

peejay
  • Members
  • 39 posts
  • Last active: Jul 09 2009 11:30 AM
  • Joined: 04 Mar 2005
Very nice! I'm using Laszlo's enhanced version (the one that works on any window) on my laptop now.
I changed one thing: I noticed that often, when I clicked a key several times, it would be added only once to the active application, so I added SetWinDelay to the beginning of the code:
SetWinDelay, 0

; See Laszlo's enhanced version for the rest of the code
Edit: at first I added SetBatchLines, -1 to the code as well, but, as Laszlo pointed out, it didn't improve performance, see the posts below.
The Gods smile upon you. Beware - it is probably because they know what is going to happen to you next, and find it amusing. To them, anyway. --- Discworld Horrorscope: http://www.weirdnes.....uk/stars3.html

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
SetWinDelay 0 is a good idea! On the other hand, SetBatchLines -1 does not seem to have any effect on my system: XP SP2, Centrino laptop. Do you see any speedup with that?

peejay
  • Members
  • 39 posts
  • Last active: Jul 09 2009 11:30 AM
  • Joined: 04 Mar 2005

SetWinDelay 0 is a good idea! On the other hand, SetBatchLines -1 does not seem to have any effect on my system: XP SP2, Centrino laptop. Do you see any speedup with that?

Hmmm, no. I added them at the same time, and was too busy (or too lazy) to find out which addition made the difference. I removed SetBatchLines from my previous post, as SetWinDelay does the trick. Thanks for clarifying that.
The Gods smile upon you. Beware - it is probably because they know what is going to happen to you next, and find it amusing. To them, anyway. --- Discworld Horrorscope: http://www.weirdnes.....uk/stars3.html

bLisTeRinG
  • Members
  • 45 posts
  • Last active: Nov 07 2012 11:15 AM
  • Joined: 15 Nov 2004
I'm a lazy person really. Sometime I just can't be bothered with the keyboard, so I mutated your excellent offering for anyone out there like me. By the way I'm using Windows 98se.

Update
Now it's a bit more 'ergonomic' (quicker). This updated version adds punctuation etc. Next time I have a look I'll try to deal with edit-fields such as file-renaming in explorer, at the moment they close after the first character is transfered. Another possibility is to transmit to the Clipboard. We'll see. If anyone wants to have a go, then do. All assistance appreciated! ':)'

;Mutated from: Martin O'Neills Excellent Numberpad Idea.
;miniKeys by bLisTeRinG v0.1 april2006

SetTimer GetActiveWindow

;Gui, -Caption 
gui Color, Green, Yellow
gui +AlwaysOnTop
gui, font, S10, Arial Narrow
Gui Add, DropDownList, x5   y2  w30 h10 R4  gButton, a||b|c|d|
Gui Add, DropDownList, x34  y2  w30 R4  gButton, e||f|g|h|
Gui Add, DropDownList, x65  y2  w30 R6  gButton, i||j|k|l|m|n|
Gui Add, DropDownList, x96  y2  w30 R6  gButton, o||p|q|r|s|t|
Gui Add, DropDownList, x127 y2  w30 R6  gButton, u||v|w|x|y|z|
gui, font, S8, Arial Narrow
Gui Add, DropDownList, x5 y28 w34 h12 R12 gButton, F1||F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|
gui font, Cred S9, Arial Narrow
Gui Add, Button, x44  y29  w36 h21 gButton, Space
gui font,  CPurple) S12
Gui Add, Button, x83  y29  w36 h21 gButton, TAB
gui, font, S10, Arial Narrow
Gui Add, DropDownList, x122 y28 w35 R22 h10 gButton, .||,|;|:|\|~|!|@|#|$|^|&|(|)|?|Space|Tab|
gui font, S14, Arial Bold
Gui Add, Button, x5   y52  w36 h29 gButton, 7
Gui Add, Button, x5   y82  w36 h29 gButton, 4
Gui Add, Button, x5   y112 w36 h29 gButton, 1
gui font, Arial Bold S20
Gui Add, Button, x5   y142 w17 h29 gButton vBS, «
Gui Add, Button, x24  y142 w17 h29 gButton vDel, »
gui font, Arial Bold S14
Gui Add, Button, x44  y52  w36 h29 gButton, 8
Gui Add, Button, x44  y82  w36 h29 gButton, 5
Gui Add, Button, x44  y112 w36 h29 gButton, 2
Gui Add, Button, x44  y142 w36 h29 gButton, 0
Gui Add, Button, x83  y52  w36 h29 gButton, 9
Gui Add, Button, x83  y82  w36 h29 gButton, 6
Gui Add, Button, x83  y112 w36 h29 gButton, 3
Gui Add, Button, x83  y142 w36 h29 gButton, =
Gui Add, Button, x122 y52  w36 h29 gButton, /
Gui Add, Button, x122 y82  w36 h29 gButton, *
Gui Add, Button, x122 y112 w36 h29 gButton, -
Gui Add, Button, x122 y142 w36 h29 gButton, +
Gui Add, Button, x5   y172 w75 h29 gButton, Esc
Gui Add, Button, x83  y172 w75 h29 gButton, Enter

Gui Show, x446 y364 h205 w160, Key±Pad
WinActivate Key±Pad
WinGet KPID, ID, A
return

; SEND KEYS
Button:
   WinActivate ahk_id %LastID%
   Send {%A_GuiControl%}
Return

; SEND STRING
Word:
   WinActivate ahk_id %LastID%
   Send {veniceflo}

Return
; PrintScreen?

GuiClose:
ExitApp

GetActiveWindow:
   WinGet ID, ID, A
   IfNotEqual ID,%KPID%, SetEnv LastID,%ID%
Return


newtoit
  • Guests
  • Last active:
  • Joined: --
Hi, I just found this and it's very easy to customize; I'm very glad.
Howaver, it would be nice to have the "Enter" key with less characters, like "Ent".
Does anyone knows how to do it?
Thanks

newtoit
  • Guests
  • Last active:
  • Joined: --
OK, I already found it:

gButton vEnter, Ent

This is very nice to use!
Here is the code I use to have my numeric keypad, enjoy:

;Mutated from: Martin O'Neills Excellent Numberpad Idea.
;miniKeys by bLisTeRinG v0.1 april2006

SetTimer GetActiveWindow

;Gui, -Caption
SetWinDelay, 0
gui Color, Gray
gui +AlwaysOnTop
gui font, S14, Arial Bold
Gui Add, Button, x5 y5 w42 h32 gButton, 7
Gui Add, Button, x5 y40 w42 h32 gButton, 4
Gui Add, Button, x5 y75 w42 h32 gButton, 1
Gui Add, Button, x5 y110 w42 h32 gButton, 0
Gui Add, Button, x50 y5 w42 h32 gButton, 8
Gui Add, Button, x50 y40 w42 h32 gButton, 5
Gui Add, Button, x50 y75 w42 h32 gButton, 2
Gui Add, Button, x50 y110 w42 h32 gButton, -
Gui Add, Button, x95 y5 w42 h32 gButton, 9
Gui Add, Button, x95 y40 w42 h32 gButton, 6
Gui Add, Button, x95 y75 w42 h32 gButton, 3
Gui Add, Button, x95 y110 w42 h32 gButton, .
Gui Add, Button, x140 y5 w42 h32 gButton vBS, Del
Gui Add, Button, x140 y40 w42 h102 gButton vEnter, Ent

Gui Show, x0 y810 h145 w187, VirtualKey
WinActivate VirtualKey
WinGet KPID, ID, A
return

; SEND KEYS
Button:
WinActivate ahk_id %LastID%
Send {%A_GuiControl%}
Return

; SEND STRING
Word:
WinActivate ahk_id %LastID%
Send {veniceflo}
Return

GuiClose:
ExitApp

GetActiveWindow:
WinGet ID, ID, A
IfNotEqual ID,%KPID%, SetEnv LastID,%ID%
Return