When I press the middle mouse button I want to perform some key combos, then hold a different mouse button until I release the one I am pressing, then do some more key combos without passing the original mouse button to the active window. I can get it all to work except that the button being pressed is also sent to the active window.
Is this possible?
I've tried a number of solutions but they all either block mouse movement (required), mess with mouse movement even when the button isn't pressed, or cause the script to think I released the button.
#include <Misc.au3>
Opt("WinTitleMatchMode", 2) ;match partial names of windows
MsgBox($MB_SYSTEMMODAL, "Window", "Script started.")
Func OneNotePan()
Send("{alt}dy")
MouseDown($MOUSE_CLICK_LEFT)
While _IsPressed("04") ;do nothing while the middle button is held
WEnd
MouseUp($MOUSE_CLICK_LEFT)
Send("{Alt}dt{Alt}h{Esc}{Esc}")
EndFunc
Func AcrobatPan()
;MsgBox($MB_SYSTEMMODAL, "Window", "Acrobat is active.")
Send("{Space down}")
MouseDown($MOUSE_CLICK_LEFT)
While _IsPressed("04") ;do nothing while the middle button is held
WEnd
MouseUp($MOUSE_CLICK_LEFT)
Send("{Space up}")
EndFunc
Func VisioPan()
Send("{CtrlDown}{ShiftDown}")
MouseDown($MOUSE_CLICK_RIGHT)
While _IsPressed("04") ;do nothing while the middle button is held
WEnd
MouseUp($MOUSE_CLICK_RIGHT)
Send("{CtrlUp}{ShiftUp}")
EndFunc
Func IdentifyApp()
;MsgBox($MB_SYSTEMMODAL, "Window", "Middle button down.")
if WinActive("OneNote") Then
OneNotePan()
Elseif WinActive("Acrobat") Then
AcrobatPan()
;MsgBox($MB_SYSTEMMODAL, "Window", "Acrobat is active.")
Elseif WinActive("Visio") Then
VisioPan()
;MsgBox($MB_SYSTEMMODAL, "Window", "Visio is active.")
EndIf
EndFunc
while 1
if _IsPressed("04") Then IdentifyApp()
Sleep (500) ;keep script running
WEnd