A method that doesn't involve AHK:
I went with another method that involved putting a script somewhere visible to %PATH% and editing the registry to call the script.
That registry edit is as follows:
Set key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\18\ShellExecute
to value "scriptname.wsf" which is whatever you choose to name the script file.
The script I used was:
<package>
<job id="vbs">
<script language="VBScript">
Set WshShell = WScript.CreateObject ("WScript.Shell")
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
For Each objProcess in colProcessList
If objProcess.name = "Calculator.exe" then
vFound = True
End if
Next
If vFound then
WshShell.AppActivate "Calculator"
Else
WshShell.run "calc.exe", 5, false
End If
</script>
</job>
</package>
This was based on an answer to the Stack Overflow question How to run single instance of calculator (calc.exe) in Windows.
But the script they wrote didn't work in Windows 10, so I combined some bits from other sources to make mine, which does. A miracle, since I know nothing about VBScript, but it's a functioning option, if you don't want to run AHK.
calcmultiple times)? – Ƭᴇcʜιᴇ007 Sep 16 '15 at 18:26