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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rspai
Posts: 9
Joined: 15 Oct 2019, 03:38

Sending key when Mouse button clicked at certain point on screen

11 Apr 2021, 09:58

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.
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

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

11 Apr 2021, 10:09

Hallo,
perhaps:

Code: Select all

#IfWinActive ahk_class IrfanView
~LButton::
MouseGetPos,, ypos
If (ypos >170 and ypos <570)
{
	ToolTip %ypos%
	Send, {Space}
}
#IfWinActive
Return
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

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

11 Apr 2021, 10:09

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, doanmvu and 290 guests