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

Add comment

Your rating:

Submit

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

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

Please publish modules in offcanvas position.