File run when GUI button released. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hazyskylines
Posts: 1
Joined: 13 Jan 2018, 16:07

File run when GUI button released.

13 Jan 2018, 16:11

I would like to know how to have a file run when a GUI button is released. I am very new to AHK, so any help would be much appreciated. I have tried using KeyWait, but it doesn't appear that KeyWait works with GUI buttons.
User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: File run when GUI button released.

13 Jan 2018, 16:58

Why when the button is released instead of when the button is pressed?

As Bobo suggested OnMessage probably would be better.

But this should work also when the left button is released.

Code: Select all

gui, add, button,,Continue
Gui, show, autosize
return

~lbutton up::
MouseGetPos,,,,Control
if Control = button1
 goto ButtonWasReleasedLabel
return

ButtonWasReleasedLabel:
MsgBox continue button was released
return

GuiEscape:
exitapp
Last edited by DataLife on 13 Jan 2018, 17:12, edited 1 time in total.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: File run when GUI button released.  Topic is solved

13 Jan 2018, 17:12

Here is an example using OnMessage

Code: Select all

OnMessage(0x201, "WM_LBUTTONDOWN")

gui, add, button,,Continue
Gui, show, autosize
return

WM_LBUTTONDOWN()
{
MouseGetPos,,,,Control
if Control = button1
 gosub ButtonWasReleasedLabel
return
}

ButtonWasReleasedLabel:
MsgBox button was released
return

GuiEscape:
exitapp
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: tabr3 and 144 guests