'Autohotkey left click (or right) on screen triggered via hotkey not working

Hy Guys,

I am running Autohotkey v1.1.32.00 (if that matters) and trying to do a Left click when hotkey ctrl + alt + m is pressed irrespective of the window or program basically any part of the screen where current mouse position is. The main purpose is to set focus to the window or part of the window via hotkey press then manually left click, basically do a left mouse click whenever hotkey is pressed. But its not working.

Not Working

^!m::
  MouseClick, Left
return

However, what works is when the #IfWinActive ahk_exe my_program.exe condition is used (as shown):

#IfWinActive ahk_exe chrome.exe
^!m::
  MouseClick, Left
return

The problem with above is it only works for chrome.exe, I want it to work irrespective of the program running. Basically left click wherever the mouse position on screen is.

I even tried the suggestion in following question, i.e to create a new script file and run that script file, but that didn't work

Autohotkey right click

Any help appreciated.

Thanks



Solution 1:[1]

Try:

#InstallMouseHook
!^m::
Send, {LButton} ; OR {RButton} as you desire.
/*
OR alternatively it might be just too fast to be recognized
Send, {LButton down}
Sleep 300
Send, {LButton up}
*/
Return

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1