Jump to content
Sign in to follow this  

perm bind numpad to calc

Recommended Posts


I'm working on a program to bind all of the numpad keys to activate calculator, send the keypress, and then reactivate the previous window -- The problem is that, generally, I can enter numbers on the keypad faster than windows switches back and forth. I would like to make my script stall before switching back to the previous window. Ideally, I would want it to wait until no key has been pressed for a set amount of time (500 ms?). Here's what I'm doing now:

Func num1()
;**Here is where I would like the user to be able to type whatever as much as they'd like w/o the program doing anything until it has been 500 ms since they're last keypress.  if there is a 500ms break w/o any keys pressed, the program will continue on.**

What do you think?

Also, I'm primarily using this to work in excel -- punching in spreadsheets and doing occasional calculations that need entered into cells. I've found with what I have, though, that all of my hotkeys work in switching to calc and back, except numpadenter just moves down a cell in excel. help?

Share this post

Link to post
Share on other sites

I'm not sure about your numpad enter key problem, but for the 500ms timeout take a look at _Timer_SetTimer() in the help file.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post

Link to post
Share on other sites

This isn't quite what you wanted, but it could work...

Press numlock to show and hide calculator

HotKeySet("{NUMLOCK}", "Calc")

If NOT ProcessExists("Calc.exe") then Run("calc.exe")

While 1
Func GetNumLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",144)
    If Abs($ret[0]) = 127 then Return 1
    Return 0

Func Calc()
    Switch GetNumLock()
        Case 1
            WinSetState("Calculator", "", @SW_SHOW)
        Case 0
            WinSetState("Calculator", "", @SW_HIDE)

Share this post

Link to post
Share on other sites

thanks to both of you guys!


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this