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