1
votes

Im windows8 user, and Im trying to switch left and right buttom only inside Irfanview (picture viewer application) because the default pan always is left mouse buttom, but in irfan view is the right mouse buttom, So I want to whenever I hold down left mouse button, it send hold down right mouse buttom instead. I have tried this macro: it works inside Irfanview but also affect windows desktop, and sometimes some other programs also.

#NoEnv
#SingleInstance, Force
#Persistent
#InstallMouseHook

#ifWinActive ahk_class IrfanView
LButton::RButton
RButton::LButton

#IfWinActive ahk_class FullScreenClass
LButton::RButton
RButton::LButton

Could someone please give me some advice, pehaps is the conditional??

Thanks advanced.

1
Does this only happen when IrfanView is active and you click somewhere outside IrfanView's window, e.g. the Desktop beneath it? This is the only scenario in which I could reproduce this behaviour.MCL

1 Answers

1
votes

The behavior you are seeing is most likely due to the fact that one of your selected windows is activated, and you are trying to click on another window.

The solution to this would be to make your hotkeys use the window class the mouse is over instead of the active window. I've included a function and how to use it below:

#If (MouseIsOverClass("IrfanView") or MouseIsOverClass("FullScreenClass")) and !MouseIsOverControl("IrfanViewerClass1")
    LButton::RButton
    RButton::LButton

MouseIsOverClass(WinClass) 
{
    MouseGetPos,,,win
    WinGetClass,class,ahk_id %win%
    return (class = winClass)
}

MouseIsOverControl(winControl)
{
    MouseGetPos, , , , Control
    return (Control = winControl)
}

EDIT: Note that #If is only supported in AHK_L.

Documentation