The Case of the Failing Focus (or How I Fixed the Calculator Button on My Keyboard)

CalcKey

Ahh, my good ol’ Microsoft Wireless Laser Keyboard 6000 v2.0. I settled upon this keyboard many years ago, and have used it both at work and at home ever since. One of the handiest features is the conveniently-placed calculator button. It’s a simple thing, really, and isn’t exclusive to this keyboard, by any means. Tap the calculator button, wait for the calculator app to launch, move your hand down to the number keys, and start calculating.

On Windows 7, the calculator key (or more appropriately, the software driving the key) was a bit hit and miss. On some computers, hitting the key would open a new calculator instance each time. By that I mean, instead of pulling into focus a calculator app that is already running, it would instead keep opening new calculator apps. On others, it would follow the preferred route and bring into focus the currently open calculator, or open the calculator application if it wasn’t already running.

Well, with Windows 10, things have made a turn for the worse. Hit the calculator key and the calculator will open, but it won’t quite be in focus. It’s selected, but if you start typing, nothing will happen. You have to select the entry area with your mouse, then start typing. Frustrating, to say the least. Additionally, the key will open a new instance of the calculator each time it’s pressed.

This just won’t do. So, how do we fix these issues? Keep reading for the answer…

As demonstrated by this forum post, I’m not the only one experiencing these calculator problems. The users in the aforementioned post have come up with a few workarounds, but they’re hacks at best. Uninstall the Microsoft Mouse and Keyboard Center? That’s hardly a real solution, and you’d lose quite a bit of functionality in doing so. One user suggested setting up a macro to launch the Start Menu, type in “calc.exe”, then hit Enter. Nice way to think out of the box, but unreliable. Plus, neither of these options solve the issue of opening multiple calculators.

My solution was to write a simple VB.Net program that, when executed, looks for and brings into focus an existing calculator instance. If the calculator isn’t already running, then it will start and properly set focus to it. So, a launcher for calc.exe, which is itself a launcher for the Windows App calculator.exe. I then set my calculator key to run my special launcher, instead of calc.exe. The calculator button now works exactly as one would expect.

I suspect the switch to a Windows-App-based calculator is the cause of the focus problems. It’s no longer a normal desktop app that’s running. Instead, it’s a Modern style app, running in Windows 10’s new windowed-app mode. This also resulted in some peculiarities when writing code to find and focus on the proper windows. On Windows 7 systems, the app is running in its own window frame (CalcFrame), while on Windows 10 its running in the more generic Windows App frame (ApplicationFrameWindow). The launcher I put together will look for both windows, so it should work on most Windows systems.

Note that my launcher app was primarily designed to fix issues with the calculator button on Windows 10 systems. Windows 7 support was secondary, so I can’t guarantee that it will work on Windows 7 systems (but it should). Of course, I can’t guarantee it will work on Windows 10 systems, either (but it should).

Windows puts a lot of effort into stopping programs from launching and focusing on other programs’ windows. It’s a security measure they implemented back in the Windows XP days. As a result, my program uses a number of different methods to try and bring the calculator window into view. It seems to be working, but I wouldn’t be surprised if there are instances where it doesn’t.

Putting LaunchCalc.exe to Use

Want to put the app to use on your own system? Download it here. You can also view and download the app’s source code. I targeted .Net 3.0, so most will be able to use the app right out of the box. If you don’t have .Net installed, then you can go here to download a version. Any version greater than or equal to 3.0 should let you run this app.

Downloaded the app? Great, now place it somewhere on your hard drive. In C:\LaunchCalc\ would work, for example. To modify the calculator button through the Microsoft Mouse and Keyboard Center, follow these steps.

  • Click the start button and start typing Microsoft Mouse and Keyboard Center. Click the icon once it pops up.
  • Switch to the keyboard settings (if you’re not already on it), scroll down to the Calculator button, and click on it.
  • Choose the “Open a program, webpage, or file” option, then browse for the LaunchCalc.exe program.
  • Close the Mouse and Keyboard Center, and you should be all set.

Changing the Calc Button on a Dell Laptop

Here’s a bonus tip… Have a Dell laptop? Well, many now have a Calc button built in to the keyboard. I suspect other laptops do, as well, but I can’t confirm whether or not this fix will work with other manufacturers’ devices. Why not give it a try and let me know? Anyway, to change what app that button calls, so that your Dell laptop will use my LaunchCalc app, for example, change the following value in the registry:

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\18
Value: ShellExecute

By default, the ShellExecute key will contain “calc.exe”. You can enter anything you like for this value, changing the Calc button to open whatever program you desire. To change it to launch my LaunchCalc.exe program, simply change the value to the full path of the program. For example, “C:\LaunchCalc\LaunchCalc.exe”.

Don’t feel comfortable editing the registry? One false step can make for quite the disaster, so I can’t blame you. Follow these directions to create a file to edit the registry via a simple double-click of your mouse.

  • Create a new .txt file on your computer. Right-click on your desktop, go to New, then Text Document.
  • Name the file “ModifyCalcButton.reg”.
  • Right-click the file and choose Edit.
  • Copy the code below and paste it into your new file. Note that you need to copy the “Windows Registry Editor Version 5.00” line, as well.
  • Modify “C:\LaunchCalc\LaunchCalc.exe” to correspond to where you have saved the launcher program. Make sure to keep the quotes around the file path.
  • Save the file, then close it.
  • Double-click the file, read and respond to the security message that pops up, allowing the changes to the registry, and then you’re done.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\18]
"ShellExecute"="C:\LaunchCalc\LaunchCalc.exe"

Go Forth and Calc

That’s it. Your Calc button, in whatever form, will now launch my LaunchCalc.exe program. Hopefully you’ll find the functionality of the button to be much improved.


  • JoeB

    Thanks Dan! Works like a charm, no idea why they can’t sort this sort of thing and provide options for customizing this in their new calculator app.

  • JayWhy

    This was driving me nuts, big thanks! I had to check “Unblock” in the app properties (bottom of the General tab), works great now.

  • csinclaire

    You’ve saved me twice — once on my old computer after I upgraded to Win 10, and once on the new computer that I had to get after the old computer screwed up after I upgraded to Win 10. Thanks much!

  • Mark Lawton

    Thank you, thank you, thank you!! Can buy you a pint (or half depending on where you live and how much a pint costs)?

  • Heiko

    unfortunately this does not solve the problem. hitting the calculator button (or starting “LaunchCalc” always opens a new calculator app and don’t return to the already open calculator.
    Is there any other solution?

  • Constantine

    Thank you sir, very helpful.

  • ADn

    Thank you a lot!

  • http://about.me/neskhodovskiy Sergey Neskhodovskiy

    Win 10, Logitech K800 with a dedicated calculator button. Your app mainly did the job for me, the calculator launches and input has the focus immediately so I can start typing numbers. Million thanks for that!

    As a side note, it didn’t solve the issue of multiple instances of calculator on repeated button hit. But that’s so much secondary to the main issue which I now can kiss goodbye. Keep up the good work Dan!

  • Jeff

    Awesome! Works great for me. However, I want to use it for something other than the calculator. Any chance you could modify to use a param for the target? Maybe you could even recompile it for us 😉

  • Ali

    THANK YOU !!!

  • Vegas Zipper

    Thank you sir!! Just used this on my Logitech Wireless Wave Mouse/Keyboard combo. Haven’t put it through its paces just yet, but right off the bat it’s working exactly as you said. Brings the calc into focus (which used to work for me just fine until the latest Windows 10 update), but now also eliminates opening a new calc every time I press the button. You’re the man!