Jump to content

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()
    Unbind()
    $activewin=Wingettitle("")
    winactivate("Calculator")
    send("{NUMPAD1}")
;**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.**
    winactivate($activewin)
    rebind()
EndFunc

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?

Link to comment
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
Link to comment
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
sleep(100)
WEnd
    
    
Func GetNumLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",144)
    If Abs($ret[0]) = 127 then Return 1
    Return 0
EndFunc

Func Calc()
    Switch GetNumLock()
        Case 1
            WinSetState("Calculator", "", @SW_SHOW)
            WinActivate("Calculator")
        Case 0
            WinSetState("Calculator", "", @SW_HIDE)
    EndSwitch
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...