GuiLButton similar to GuiEscape? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

GuiLButton similar to GuiEscape?

10 May 2021, 10:46

I'm playing around with simple gui's with AHK. In one example I found, pressing the escape key will exit the gui, example shown below. I would like to replicate this behavior, but for a right or left click of the mouse. Is there an equivalent, perhaps GuiLButton?

Code: Select all

GuiEscape:
    gui_destroy()
    return
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: GuiLButton similat to GuiEscape?  Topic is solved

10 May 2021, 11:09

Code: Select all

LButton::
RButton::
GuiEscape:
Gui, Destroy
Return
Alternative is OnMessage with a system message. OnMessage pertains only to the script's window, which in most uses pertains to a GUI.
likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: GuiLButton similat to GuiEscape?

10 May 2021, 11:11

Does this effectively remap my LButton and RButton permanently? Any chance this may impact my computer's performance?
likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: GuiLButton similat to GuiEscape?

10 May 2021, 11:36

I found that this solution blocks Lbutton and Rbutton. My concern is that this remaps the clicks. I would only want LButton and RButton to be remapped if the GUI is opened.
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: GuiLButton similat to GuiEscape?

10 May 2021, 11:50

Yes, the buttons are "trapped" until changed, or until the script exits. If you just want to click on the GUI instead, then see the alternative that I mentioned in the post.

More broadly, one can use an #If directive to provide a required context for a hotkey; explained in the documentation, with examples.

I have never found that the mere existence of a hotkey affects performance. You can always measure it through a CPU monitor, etc. The design of a hotkey routine could affect performance when that routine is being executed.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, downstairs, filipemb, OrangeCat, roysubs and 159 guests