One nice thing about the common heritage of ahk/AutoIt3 is compatible format for hotkey strings. ahk handles Mouse hotkeys while AutoIt3 is weak in that area.
I use this ahk script to catch Shift-MiddleMouseClick and send the hotkey string passed in on the command line:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayIcon
#SingleInstance force
If 0 < 1
{
Exit
}
Else
{
hkey = %1%
}
+MButton::
GoSub,DoClick
Return
DoClick:
Send %hkey%
Return
It should be portable to servicing non-AutoIt3 programs. You would just have to put the appropriate string as command line param. Also it's easy to read the mouse hotkey from an .ini file to make it "adjustable" to different programs. Not many programming languages handle mouse hotkeys as easily as ahk. So this is a nice simple adapter.
Note, by using #SingleInstance force
you can change the hotkey sent by just launching the program again using a different param.
Here's an example of testing for mouse hotkey in .ini file. If not present it sets it to the default. It should work in both script(.ahk) and compiled script(.exe) cases:
IniFile = %A_ScriptDir%\%A_ScriptName%
IniFile := RegExReplace(IniFile,"i)ahk$","ini")
IniFile := RegExReplace(IniFile,"i)exe$","ini")
IniRead,MouseHotkey,%IniFile%,Settings,MouseHotkey,%A_Space%
If MouseHotkey =
{
MouseHotkey := "!MButton"
}
Hotkey,%MouseHotkey%,DoClick,UseErrorLevel
If ErrorLevel
{
MsgBox, 4112, PromptHere, %MouseHotkey% is not a valid Hotkey
ExitApp
}
Return
edit: btw I use the default Pause key. For those who don't like to let go of the mouse to hit a hotkey, you should be able to modify the scripts to produce something that sends "{Pause}" when you click middle mouse button, as example, to open FARR. (Although, since I'm going to type into the search box anyway, keyboard-only hotkey is not detrimental to me in FARR. Just an example since the topic came up.)