How to prevent hotkeys from being eaten Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Grindcore
Posts: 10
Joined: 22 Oct 2015, 14:33

How to prevent hotkeys from being eaten

20 Apr 2016, 03:31

Hello :) If I write a script in the form of

Click:: bla bla

It "eats" the left click itself. If I add

Click::
Click
bla bla

Then it does left click, but I can't drag a bog anymore for example. I don't want AHK to interact with the click, only react to it.


I also tried to get around this with OnMessage instead of using hotkeys. On the help page there's an example of a left click triggering a tooltip whenver you click anywhere in a GUI, but I don't know how to get it to work without the GUI.

Gui, Add, Text,, Click anywhere in this window.
Gui, Add, Edit, w200 vMyEdit
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
return

WM_LBUTTONDOWN(wParam, lParam)
{
X := lParam & 0xFFFF
Y := lParam >> 16
if A_GuiControl
Control := "`n(in control " . A_GuiControl . ")"
ToolTip You left-clicked in Gui window #%A_Gui% at client coordinates %X%x%Y%.%Control%
}

GuiClose:
ExitApp

If I make any sort of alteration to the code simply nothing happens. The way I understand this example, the 0x201 message is the windows system message for the mouse being left clicked, and it's triggering the WM_LBUTTONDOWN function. So in this function I could put my own code. But as soon as I remove the GUI part from the code it stops triggering. I simply want it to work all the time instead of only in the GUI :)


Thanks!
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: How to prevent hotkeys from being eaten  Topic is solved

20 Apr 2016, 04:21

You need to prepend the ~ modifier: ~LButton::Soundbeep. Keep in mind though, activating/creating other windows might still interfere with clicks.
User avatar
1A_OS
Posts: 10
Joined: 14 Apr 2016, 02:30

Re: How to prevent hotkeys from being eaten

20 Apr 2016, 04:30

The problem is "Click" only is the Click itself, if you wanna drag something you have to use "Click down"
1A_OS
Grindcore
Posts: 10
Joined: 22 Oct 2015, 14:33

Re: How to prevent hotkeys from being eaten

20 Apr 2016, 05:36

Thanks, both solutions worked.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 382 guests