This is as far as I got. As commented, I couldn't get the modifier hotkeys to block the key releases from the system, so the code doesn't work for the modifiers, though it works for the mouse buttons.
Code:
#UseHook
SendMode, Input
Modifiers = Ctrl|Alt|Shift
; Set up OSD
Gui, +ToolWindow -Caption +AlwaysOnTop
Gui, Margin, 0, 0
Gui, Font, S10 C002040, Arial
Gui, Add, Progress, BackgroundFFFFFF w87 h25 vbk1
Gui, Add, Progress, x+0 y0 BackgroundFFFFFF w87 h25 vbk2
Gui, Add, Progress, x+0 y0 BackgroundFFFFFF w87 h25 vbk3
Gui, Add, Text, x2 y2 w85 h21 center vtm1 BackgroundTrans, F1
Gui, Add, Text, x+2 y2 w85 h21 center vtm2 BackgroundTrans, F2
Gui, Add, Text, x+2 y2 w85 h21 center vtm3 BackgroundTrans, F3
Gui, Show, y0 NoActivate, [VxE]'s inactive mouse/modifier assistant.
OnMessage( WM_LBUTTONDOWN := 0x201, "WM_LBUTTONDOWN" )
Return
GuiEscape:
Exitapp
#IfWinExist, [VxE]'s inactive mouse/modifier assistant.
; These hotkeys are only active if the script is in 'inactive' mode
*F1:: ; press F1 to hold down the left mouse button
*F2:: ; press F2 to hold down the middle button
*F3:: ; press F3 to hold down the right button
KeyWait, % SubStr( A_ThisHotkey, 2 )
Btn := SubStr( A_ThisHotkey, 0 ) ; either 1, 2, or 3
GuiControl, +BackGroundFCBA2C, bk%Btn%
%Btn%State := 1
Click, % SubStr( "LMR", Btn, 1 ) . " Down"
Prompt := ""
Loop, Parse, Modifiers, |
If GetKeyState( A_LoopField )
Prompt .= "+" A_LoopField
StringTrimLeft, Prompt, Prompt, 1
Prompt := StrLen( Prompt ) ? Prompt : "_ _ _"
GuiControl,, tm%Btn%, %Prompt%
Gui, Show, NoActivate, [VxE]'s active mouse/modifier assistant.
Return
#IfWinExist, [VxE]'s active mouse/modifier assistant.
; All these hotkeys are context sensitive based on the gui window's title
*F1:: ; press F1 again to release the left button
*F2:: ; when the script is no longer holding a button,
*F3:: ; normal mouse function is restored
KeyWait, % SubStr( A_ThisHotkey, 2 )
Btn := SubStr( A_ThisHotkey, 0 ) ; either 1, 2, or 3
%Btn%State := !%Btn%State
Click, % SubStr( "LMR", Btn, 1 ) . ( %Btn%State ? " Down" : " Up" )
GuiControl,, tm%btn%, % ( %Btn%State ? Prompt : "F" Btn )
GuiControl, % "+BackGround" . ( %Btn%State ? "FCBA2C" : "FFFFFF" ), bk%Btn%
If ( 3 = !1State + !2State + !3State )
{
Loop, 3
GuiControl,, tm%A_Index%, F%A_Index%
Gui, Show, NoActivate, [VxE]'s inactive mouse/modifier assistant.
}
Return
; Block normal mouse clicks, these work just fine
*LButton::
*MButton::
*RButton::
*LButton Up::
*MButton Up::
*RButton Up::
; These SHOULD block the modifier key PRESSES AND RELEASES
; but I couldn't get it to work in my tests.
*LCtrl::
*LAlt::
*LShift::
*LCtrl Up::
*LAlt Up::
*LShift Up::
*RCtrl::
*RAlt::
*RShift::
*RCtrl Up::
*RAlt Up::
*RShift Up::
Return
#IfWinActive
#esc::Exitapp
WM_LBUTTONDOWN( wparam, lparam, msg, hwnd ) {
Gui, %A_Gui%:+LastFound
PostMessage, 0xA1, 2
}