Add default to a picture button

 Well there's a lot of autohotkey sites saying that you can apply a transparency and then capture special mouse events to emulate the mouseover and mouseout effects of a button with an image as a background.  I couldn't get any of these working and they looked more confusing then anything else.

My solution is to set up the default button and the image to respond to the ENTER key after you typed something (this is for a search feature) in addition to having a button if the user would rather click then press the ENTER key.  Then create the mouseover and mouseout effects afterwards.

Add the image for your GUI:

Gui, Add, Picture, x600 y70 w90 h90 vSearchButton gSearch, %A_ScriptDir%\images\program\search_button.png
  1.  Gui, Add, Picture, x600 y70 w90 h90 vSearchButton gSearch, %A_ScriptDir%\images\program\search_button.png 


Add the input field where you type the text:

Gui, Add, Edit, x55 y95 r1 w550 vSearchTextInput, Search...
  1.  Gui, Add, Edit, x55 y95 r1 w550 vSearchTextInput, Search... 


Add the submit button with a hidden attribute:

Gui, Add, Button, x600 y70 w90 h90 +Default +gSearch +Hide, Search
  1.  Gui, Add, Button, x600 y70 w90 h90 +Default +gSearch +Hide, Search 


The function to receive the data can be:

		Gui, Submit, NoHide
		MsgBox, Searching for "%SearchTextInput%"
  1.  Search: 
  2.          Gui, Submit, NoHide 
  3.          MsgBox, Searching for "%SearchTextInput%" 
  4.      Return 
Category: AutoHotkey :: Article: 226

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2022 Joel Lipman .com. All Rights Reserved.