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:

copyraw
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:

copyraw
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:

copyraw
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:

copyraw
Search:
		Gui, Submit, NoHide
		MsgBox, Searching for "%SearchTextInput%"
	Return
  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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

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:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.