Page 1 of 1

Sending key when Mouse button clicked at certain point on screen

Posted: 11 Apr 2021, 09:58
by rspai

Code: Select all

 #IfWinActive ahk_class IrfanView
        LButton::
        MouseGetPos,xpos, ypos 
        If (ypos >170 and ypos <570)
        {
        Msgbox %ypos%
        Send, {Space}
        }
        #IfWinActive
        Return
I have written the above code for sending the Space key when the Left Mouse button is clicked within a certain range on the Application window. It works when clicked within the range. However, when the Left Mouse button is clicked outside the range, the default behavior does not happen. For example, nothing happens when the Left Mouse button is clicked on the Application close button (which is outside the specified range).

Please help with inputs/solutions. Thanks.

Re: Sending key when Mouse button clicked at certain point on screen  Topic is solved

Posted: 11 Apr 2021, 10:09
by Rohwedder
Hallo,
perhaps:

Code: Select all

#IfWinActive ahk_class IrfanView
~LButton::
MouseGetPos,, ypos
If (ypos >170 and ypos <570)
{
	ToolTip %ypos%
	Send, {Space}
}
#IfWinActive
Return

Re: Sending key when Mouse button clicked at certain point on screen

Posted: 11 Apr 2021, 10:09
by mikeyww
Or:

Code: Select all

#IfWinActive ahk_class IrfanView
LButton::
MouseGetPos,, ypos
If (ypos > 170 and ypos < 570)
{
 Msgbox, %ypos%
 Send {Space}
} Else Send {%A_ThisHotkey%}
Return
#IfWinActive