Valuater Posted January 1, 2007 Share Posted January 1, 2007 (edited) *** UPDATED 7/8/2008 ***Most have seem to use the _ControlHover() for Picture buttons and have made additional complex functions to change the picturesThis does all the work for you, all you need is1 A file location$XButton_Location = @ScriptDir & "\Buttons\Style_1"2 Three button pictures ( gif, jpg or bmp ) - 22 included in demo"Normal" - "Over" - "Press"3 Create the button$Button_1 = _HoverButton ("Small", 180, 80, 70, 15, $color) - color is optional4 in the While loop_CheckHoverAndPressed ($Main_GUI_Name)************ NEW *****************Now you can use/add your own pics into a theme and it can work on "button release"__ButtonHoverTag.au3The old system is still here...._ButtonHover.au3*** FULL DEMO WITH BUTTONS ***Demo use Scriptexpandcollapse popup#include <_ButtonHover.au3> #include <File.au3> ; required ; $XButton_Location = @ScriptDir & "\Buttons\Style_1" $XButton_Location = FileReadLine(@ScriptDir & "\Buttons\BDefault.txt", 1) If Not FileExists($XButton_Location) Then $XButton_Location = FileSelectFolder("Button Folders", @ScriptDir & "\Buttons", 2) $color = "" If StringInStr($XButton_Location, "15") Then $color = 0xFFFFFF $Main_GUI = GUICreate("_ButtonHover Demo") $List = GUICtrlCreateList("", 40, 80, 100, 100) GUICtrlCreateLabel($XButton_Location, 20, 20, 400, 20) $Button_1 = _HoverButton ("Small", 180, 80, 70, 15, $color) $Button_2 = _HoverButton ("Medium", 180, 120, 90, 30, $color) $Button_3 = _HoverButton ("Long", 180, 180, 190, 30, $color) $Button_4 = _HoverButton ("Large", 180, 240, 190, 60, $color) $Button_5 = GUICtrlCreateButton("Select", 50, 200, 80, 25) GUICtrlSetTip($Button_5, "Select a Button Style") GUISetState() $FileList = _FileListToArray(@ScriptDir & "\Buttons", "*.*", 2) If (Not IsArray($FileList)) Or (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.", 5) Else For $x = 1 To UBound($FileList) - 1 If StringInStr($FileList[$x], "more") Then ContinueLoop $result = StringInStr($FileList[$x], "\", 1, -1) $final = StringTrimRight($FileList[$x], $result) GUICtrlSetData($List, $final, 1) Next EndIf While 1 ; required _CheckHoverAndPressed ($Main_GUI) $msg = GUIGetMsg() Select Case $msg = $Button_1 MsgBox(64, "test", " You pressed Small ", 3) Case $msg = $Button_2 MsgBox(64, "test", " You pressed Medium- long ", 3) Case $msg = $Button_3 MsgBox(64, "test", " You pressed Long ", 3) Case $msg = $Button_4 MsgBox(64, "test", " You pressed Large ", 3) Case $msg = $Button_5 Buttoner() Case $msg = -3 Exit EndSelect WEnd Func Buttoner() $New_Btn = GUICtrlRead($List) If $New_Btn = "" Then Return FileDelete(@ScriptDir & "\Buttons\BDefault.txt") FileWrite(@ScriptDir & "\Buttons\BDefault.txt", @ScriptDir & "\Buttons\" & $New_Btn) Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) Exit EndFunc ;==>ButtoneroÝ÷ Ùµ,xKÞÓ(uïÛjëh×6#include <_ButtonHover.au3> #include <File.au3> Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled ; required ; $XButton_Location = @ScriptDir & "\Buttons\Style_1" $XButton_Location = FileReadLine(@ScriptDir & "\Buttons\BDefault.txt", 1) If Not FileExists($XButton_Location) Then $XButton_Location = FileSelectFolder("Button Folders", @ScriptDir & "\Buttons", 2) $color = "" If StringInStr($XButton_Location, "15") Then $color = 0xFFFFFF $Main_GUI = GUICreate("_ButtonHover Demo") $List = GUICtrlCreateList("", 40, 80, 100, 100) GUICtrlCreateLabel($XButton_Location, 20, 20, 400, 20) $Button_1 = _HoverButton ("Small", 180, 80, 70, 15, $color) GUICtrlSetOnEvent( $Button_1, "Message") $Button_2 = _HoverButton ("Medium", 180, 120, 90, 30, $color) GUICtrlSetOnEvent( $Button_2, "Message") $Button_3 = _HoverButton ("Long", 180, 180, 190, 30, $color) GUICtrlSetOnEvent( $Button_3, "Message") $Button_4 = _HoverButton ("Large", 180, 240, 190, 60, $color) GUICtrlSetOnEvent( $Button_4, "Message") $Button_5 = GUICtrlCreateButton("Select", 50, 200, 80, 25) GUICtrlSetTip($Button_5, "Select a Button Style") GUICtrlSetOnEvent( -1, "Buttoner") GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "Exiter") $FileList = _FileListToArray(@ScriptDir & "\Buttons", "*.*", 2) If (Not IsArray($FileList)) Or (@error = 1) Then MsgBox(0, "", "No Files\Folders Found.", 5) Else For $x = 1 To UBound($FileList) - 1 If StringInStr($FileList[$x], "more") Then ContinueLoop $result = StringInStr($FileList[$x], "\", 1, -1) $final = StringTrimRight($FileList[$x], $result) GUICtrlSetData($List, $final, 1) Next EndIf While 1 ; required _CheckHoverAndPressed ($Main_GUI) Sleep(10) WEnd Func Buttoner() $New_Btn = GUICtrlRead($List) If $New_Btn = "" Then Return FileDelete(@ScriptDir & "\Buttons\BDefault.txt") FileWrite(@ScriptDir & "\Buttons\BDefault.txt", @ScriptDir & "\Buttons\" & $New_Btn) Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) Exit EndFunc ;==>Buttoner Func Message() GUICtrlSetImage(@GUI_CtrlId, $XButton_Location & "\Press" & $XBType) MsgBox(64, "Button Pressed", "you pressed button " & @GUI_CtrlId , 3) EndFunc Func Exiter() Exit EndFuncEnjoy!!!... and Happy New Year!!!8)BTW.... can you imagine the possibilities of this combined with XSkin.au3 Edited July 23, 2009 by Valuater Link to comment Share on other sites More sharing options...
James Posted January 1, 2007 Share Posted January 1, 2007 So you can use images as buttons? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
RazerM Posted January 1, 2007 Share Posted January 1, 2007 This makes using images as buttons very easy. Very nice My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Valuater Posted January 1, 2007 Author Share Posted January 1, 2007 Thanks Razer.... and i guess that also answers ICT's question Updated first post using On-Event-Mode ( because i have been asked numerous times ) 8) Link to comment Share on other sites More sharing options...
fisofo Posted January 1, 2007 Share Posted January 1, 2007 (edited) this is fantastic, thanks Valuater! edit: holy crap!! thanks for all the buttons! This is like Christmas all over again... Edited January 1, 2007 by fisofo Link to comment Share on other sites More sharing options...
fisofo Posted January 1, 2007 Share Posted January 1, 2007 Just had another thought... is there an easy way to make an action fire on button click at "ButtonRelease" instead of "ButtonPressed" ? Link to comment Share on other sites More sharing options...
fisofo Posted January 2, 2007 Share Posted January 2, 2007 I hate posting three times in a row, sorry... but I found what looks to be a small error, just wanted to give you a heads up. Line 160: $Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, $SS_NOTIFY & $SS_CENTER) shouldn't that be a BitOr for the style? Link to comment Share on other sites More sharing options...
Valuater Posted January 2, 2007 Author Share Posted January 2, 2007 (edited) I hate posting three times in a row, sorry... but I found what looks to be a small error, just wanted to give you a heads up. Line 160: $Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, $SS_NOTIFY & $SS_CENTER) shouldn't that be a BitOr for the style? Actually no, According to Autoitit it should be BitOr() ... but, after testing.. it does not work the same.... so i just left it that way... $SS_NOTIFY & $SS_CENTER But... does this create an error for you? 8) Edited January 2, 2007 by Valuater Link to comment Share on other sites More sharing options...
fisofo Posted January 2, 2007 Share Posted January 2, 2007 Actually no, According to Autoitit it should be BitOr() ... but, after testing.. it does not work the same.... so i just left it that way... $SS_NOTIFY & $SS_CENTERBut... does this create an error for you?8)well... i certainly don't want to be the one to question you.... however I saw one other thing: isn't SS_NOTIFY a forced style? and if that's the case, couldn't you just put SS_CENTER in by itself?Anyway, it's really neither here nor there, i don't want to nitpick such an awesome script, it's more of a curiosity question. Link to comment Share on other sites More sharing options...
Valuater Posted January 2, 2007 Author Share Posted January 2, 2007 well... i certainly don't want to be the one to question you.... however I saw one other thing: isn't SS_NOTIFY a forced style? and if that's the case, couldn't you just put SS_CENTER in by itself?Anyway, it's really neither here nor there, i don't want to nitpick such an awesome script, it's more of a curiosity question.again, i do remember testing... the view was different, try it yourself8) Link to comment Share on other sites More sharing options...
Achilles Posted January 2, 2007 Share Posted January 2, 2007 Wow, this is awesome... Thanks!!! My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Shevilie Posted May 14, 2007 Share Posted May 14, 2007 Trolling for UDF list Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
LondonNDIB Posted June 20, 2007 Share Posted June 20, 2007 Very good! This was really what I was looking for! LD Link to comment Share on other sites More sharing options...
LondonNDIB Posted June 21, 2007 Share Posted June 21, 2007 I must be missing something... how do I make it work with more than one button on the GUI?? If I do something like this$XButton_Location = "z:\bin\images\folder" $Button_JobAdd_Folder = _HoverButton ( "", 5, 5, 150, 48 ) $XButton_Location = "z:\bin\images\file" $Button_JobAdd_File = _HoverButton ( "", 5, 55, 150, 48 ) $XButton_Location = "z:\bin\images\drive" $Button_JobAdd_Drive = _HoverButton ( "", 5, 105, 150, 48 ) $XButton_Location = "z:\bin\images\cancel" Then of course $XButton_Location just ends up being whatever the last one that was declared is. They initially show correctly, but as soon as you hover, it shows the last image in its place. There must be some way to use more than one but I can't figure it out. Or am I limited to one hover image per gui? Thanks LD Link to comment Share on other sites More sharing options...
Valuater Posted June 22, 2007 Author Share Posted June 22, 2007 There are 3 images total regular, mouse-over, and clicked These are called "theme" buttons, there is only "1" Style available with the three action/pics as stated above 8) Link to comment Share on other sites More sharing options...
Valuater Posted February 22, 2008 Author Share Posted February 22, 2008 From a PM....Hi, I'm trying your _ButtonHover() UDF and I lost my @crlf/@cr/@lf on my buttons. I tried looking at the UDF, but couldn't figure out how to fix this since it seems that the text area is a label which I believe is suppose to allow line breaks. Do you have an idea of how to fix this, or should I post this to the forum.Thanks for any help......Also, can you see a way to do guictrlset with this. Currently I have my button text changing according to buttons that are pressed. I suppose I could probably hide/show button to work around this, but if you can see a way to fix this, would be much appreciated.Let me take a look8) Link to comment Share on other sites More sharing options...
martin Posted February 22, 2008 Share Posted February 22, 2008 Actually no, According to Autoitit it should be BitOr() ... but, after testing.. it does not work the same.... so i just left it that way... $SS_NOTIFY & $SS_CENTER But... does this create an error for you? 8) This is dragging up an old post but I agree with fisofo a bit. $SS_NOTIFY = 0x0100 $SS_CENTER = 0x01 If you want both styles then the combined style is BitOr($SS_NOTIFY,$SS_CENTER) which is 0x0101. In comparison 0x0100 & 0x01 = 0x0A01 which is the same as BitOr($SS_CENTER,$SS_CENTERIMAGE, 0x0800) Maybe 0x0800 does nothing so the style should be BitOr($SS_CENTER,$SS_CENTERIMAGE) So I tried it like that, ie $Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, BitOr($SS_CENTER,$SS_CENTERIMAGE));$SS_NOTIFY & $SS_CENTER) and it looks the same to me, so I suspect you hit on the right effect by luck. (Hope you will forgive my cheek!) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Valuater Posted February 23, 2008 Author Share Posted February 23, 2008 I just couldn't understand how $SS_CENTERIMAGE could have anything to do with text on a label ... well, it works!! ************** Sorry, Champak. I couldn't find a good answer for you. 8) Link to comment Share on other sites More sharing options...
JustinMeyer Posted May 3, 2008 Share Posted May 3, 2008 Well.... I have been using AutoIt for about 2 years and this is my first post. I think it would be great to use the _ButtonHover() UDF with an icon. I have tried GUICTRLSETIMAGE , GUICTRLCREATEICON and disable it, and GUICTRLGREATEPIC and disabling it. The createpic and createicon works the best that I have found except that when the cursor is over the pic or icon the button returns to normal state even though the set tip still works in the same space.... any suggestions ;NO RESPONSE ;$SETTINGS_BUTTON_ICON = GUICtrlSetImage($SETTINGS_BUTTON,$SETTINGS_ICON) ;DISABLES ROLL OVER $PIC_TEST = GUICtrlCreatePic("F:\My Documents\My AutoIT\DARK-NET\GRAPHICS\BACKGROUNDS\TRANS (0).JPG",924,9,16,16) GUICtrlSetState($PIC_TEST,$GUI_DISABLE) ;DISABLES ROLL OVER ;$SETTINGS_BUTTON_ICON = GUICtrlCreateIcon($SETTINGS_ICON,"",924,9,16,16) ;GUICtrlSetState($SETTINGS_BUTTON_ICON,$GUI_DISABLE) Link to comment Share on other sites More sharing options...
Champak Posted May 26, 2008 Share Posted May 26, 2008 I figured out what is causing the line feed and carriage returns in the labels on the buttons. It is the ss_notify and the ss_centerimage. Once those are removed, and only ss_center remains, the carriage returns and line feeds pass through without a problem. So a workaround was to pass an extra parameter to the function to offset the label. I would have done an automatic compensator like move the label down half the size of the button to vertically center it, except I couldn't get that to work correctly if the label consisted of more tan one line. So here is my workaround....however, if someone could figure out why the ss_notify and ss_centerimage is messing it up, that would be nice: Func _HoverButton($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, $XBcolor = "", $XBsize = "", $XBweight = "", $XBVOffset = "") If Not FileExists($XButton_Location & "\") Then MsgBox(64, "Error", " $XButton_Location - was not found ", 3) Return EndIf If FileExists($XButton_Location & "\Normal.gif") Then $XBType = ".gif" ElseIf FileExists($XButton_Location & "\Normal.jpg") Then $XBType = ".jpg" ElseIf FileExists($XButton_Location & "\Normal.bmp") Then $XBType = ".bmp" Else MsgBox(64, "Error", " Unknown Button file type ( not - gif, jpg, or bmp ) ", 3) Return EndIf Local $Xbtn[2] $Xbtn[0] = GUICtrlCreatePic($XButton_Location & "\Normal" & $XBType, $XBleft, $XBtop, $XBwidth, $XBheight) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop + $XBVOffset, $XBwidth, $XBheight,$SS_CENTER);$SS_CENTERIMAGE,$SS_CENTER If $XBcolor <> "" Then GUICtrlSetColor(-1, $XBcolor) If $XBsize <> "" Or $XBweight <> "" Then GUICtrlSetFont(-1, $XBsize, $XBweight) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) _ControlHover(2, "", $Xbtn[1]) Return $Xbtn[0] EndFunc ;==>_HoverButton ...I added some other stuff too. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now