PsaltyDS Posted October 17, 2006 Share Posted October 17, 2006 Just a fun way to make a control bounce while doing something, like an install in progress. The demo bounces a button, but it could be anything: expandcollapse popup; Click on progress bar test #include <guiconstants.au3> ; Global settings Global $aProgDat[2] = [0, 1] ; [0]=Offset, [1]=Direction Global $ButtonX = 210, $ButtonY = 30 Opt("GuiOnEventMode", 1) ; Create basic GUI $GuiId = GUICreate("In-Progress Test", 300, 100, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $LabelId = GUICtrlCreateLabel("Click START to begin:", 10, 40, 180, 20, $SS_Center) $ButtonId = GUICtrlCreateButton("START", $ButtonX, $ButtonY, 60, 40) GUICtrlSetOnEvent($ButtonId, "_Button") GUISetState(@SW_SHOW, $GuiId) While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Button() Switch GUICtrlRead($ButtonId) Case "START" GUICtrlSetData($LabelId, "Running... click STOP:") GUICtrlSetData($ButtonId, "STOP") AdlibEnable("_UpdateProg", 100) Case "STOP" GUICtrlSetData($LabelId, "Click START to begin:") GUICtrlSetData($ButtonId, "START") GUICtrlSetPos($ButtonId, $ButtonX, $ButtonY) AdlibDisable() EndSwitch EndFunc ;==>_Button Func _UpdateProg() $aProgDat[0] += $aProgDat[1] If $aProgDat[0] > 5 Then $aProgDat[0] = 4 $aProgDat[1] = -1 ElseIf $aProgDat[0] < -5 Then $aProgDat[0] = -4 $aProgDat[1] = 1 EndIf GUICtrlSetPos($ButtonId, $ButtonX, $ButtonY + $aProgDat[0]) EndFunc ;==>_UpdateProg Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2006 Share Posted October 17, 2006 cute... maybe you could make it more of a UDF Func _UpdateProg($controlID) $pos = GUICtrlGetPos( $controlID) etc... 8) Link to comment Share on other sites More sharing options...
RazerM Posted October 17, 2006 Share Posted October 17, 2006 This is quite cool. 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...
PsaltyDS Posted October 17, 2006 Author Share Posted October 17, 2006 (edited) cute... maybe you could make it more of a UDF Func _UpdateProg($controlID) $pos = GUICtrlGetPos( $controlID) etc... 8) Haven't looked at that yet, the function still needs to know from some Global what the original X, Y, W, and H were for the control. But now behold! The new version bounces a SQUISHY button! [Crowd Goes Wild] Sleep(5000) [/Crowd Goes Wild] expandcollapse popup; Click on progress bar test #include <guiconstants.au3> ; Global settings Global $aProgDat[3] = [0, 1, 0] ; [0]=Offset, [1]=Direction, [2]=Squish Global $ButtonX = 210, $ButtonY = 30, $ButtonW = 60, $ButtonH = 40 Opt("GuiOnEventMode", 1) ; Create basic GUI $GuiId = GUICreate("In-Progress Test", 300, 100, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $LabelId = GUICtrlCreateLabel("Click START to begin:", 10, 40, 180, 20, $SS_Center) $ButtonId = GUICtrlCreateButton("START", $ButtonX, $ButtonY, $ButtonW, $ButtonH) GUICtrlSetOnEvent($ButtonId, "_Button") GUISetState(@SW_SHOW, $GuiId) While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Button() Switch GUICtrlRead($ButtonId) Case "START" GUICtrlSetData($LabelId, "Running... click STOP:") GUICtrlSetData($ButtonId, "STOP") AdlibEnable("_UpdateProg", 50) Case "STOP" GUICtrlSetData($LabelId, "Click START to begin:") GUICtrlSetData($ButtonId, "START") GUICtrlSetPos($ButtonId, $ButtonX, $ButtonY) AdlibDisable() EndSwitch EndFunc ;==>_Button Func _UpdateProg() If $aProgDat[2] = 0 Then $aProgDat[0] += $aProgDat[1] If $aProgDat[0] >= 5 Then ; Hit bottom $aProgDat[0] = 5 ; stop offset $aProgDat[2] += $aProgDat[1] ; Increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = -1 EndIf ElseIf $aProgDat[0] <= -5 Then ; Hit top $aProgDat[0] = -5 ; stop offset $aProgDat[2] -= $aProgDat[1] ; increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = 1 EndIf EndIf ; Move button $NewY = $ButtonY + $aProgDat[0] ; Apply squishiness to button height $NewH = $ButtonH If $aProgDat[0] = 5 Then $NewY += $aProgDat[2] $NewH -= $aProgDat[2] ElseIf $aProgDat[0] = -5 Then $NewH -= $aProgDat[2] EndIf GUICtrlSetPos($ButtonId, $ButtonX, $NewY, $ButtonW, $NewH) ; Change pos to offset and squishiness EndFunc ;==>_UpdateProg . . Edited October 17, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
fisofo Posted October 17, 2006 Share Posted October 17, 2006 But now behold! The new version bounces a SQUISHY button!Nice, I like it! Link to comment Share on other sites More sharing options...
Valuater Posted October 18, 2006 Share Posted October 18, 2006 this is what i meant... not perfected... just added to your original script expandcollapse popup; Click on progress bar test #include <guiconstants.au3> ; Global settings Global $aProgDat[3] = [0, 1, 0] ; [0]=Offset, [1]=Direction, [2]=Squish ;Global $ButtonX = 210, $ButtonY = 30, $ButtonW = 60, $ButtonH = 40 Global $GlobalID = "", $ButtonX, $ButtonY, $ButtonW, $ButtonH Opt("GuiOnEventMode", 1) ; Create basic GUI $GuiId = GUICreate("In-Progress Test", 300, 100, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $LabelId = GUICtrlCreateLabel("Click START to begin:", 10, 40, 180, 20, $SS_Center) ; $ButtonId = GUICtrlCreateButton("START", $ButtonX, $ButtonY, $ButtonW, $ButtonH) $ButtonId = GUICtrlCreateButton("START", 210, 30, 60, 40) GUICtrlSetOnEvent($ButtonId, "_Button") GUISetState(@SW_SHOW, $GuiId) While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Button() Switch GUICtrlRead($ButtonId) Case "START" GUICtrlSetData($LabelId, "Running... click STOP:") GUICtrlSetData($ButtonId, "STOP") _GlobalizeID( $GuiId, $ButtonId) AdlibEnable("_UpdateProg", 50) Case "STOP" AdlibDisable() GUICtrlSetData($LabelId, "Click START to begin:") GUICtrlSetData($ButtonId, "START") GUICtrlSetPos($ButtonId, $ButtonX, $ButtonY) $GlobalID = "" EndSwitch EndFunc ;==>_Button Func _GlobalizeID($hWin, $controlID) $GlobalID = $controlID $GID = ControlGetPos($hWin, "", $GlobalID) $ButtonX = $GID[0] $ButtonY = $GID[1] $ButtonW = $GID[2] $ButtonH = $GID[3] ;MsgBox(0x0,"Info", "$ButtonX =" & $GID[0] & @CRLF & "$ButtonY =" & $GID[1] & @CRLF & "$ButtonW =" & $GID[2] & @CRLF & "$ButtonH =" & $GID[3]) EndFunc Func _UpdateProg() If $aProgDat[2] = 0 Then $aProgDat[0] += $aProgDat[1] If $aProgDat[0] >= 5 Then ; Hit bottom $aProgDat[0] = 5 ; stop offset $aProgDat[2] += $aProgDat[1] ; Increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = -1 EndIf ElseIf $aProgDat[0] <= -5 Then ; Hit top $aProgDat[0] = -5 ; stop offset $aProgDat[2] -= $aProgDat[1] ; increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = 1 EndIf EndIf ; Move button $NewY = $ButtonY + $aProgDat[0] ; Apply squishiness to button height $NewH = $ButtonH If $aProgDat[0] = 5 Then $NewY += $aProgDat[2] $NewH -= $aProgDat[2] ElseIf $aProgDat[0] = -5 Then $NewH -= $aProgDat[2] EndIf GUICtrlSetPos($ButtonId, $ButtonX, $NewY, $ButtonW, $NewH) ; Change pos to offset and squishiness EndFunc ;==>_UpdateProg i think you can see the direction for an interchangeable control-ID, thus a UDF 8) Link to comment Share on other sites More sharing options...
dandymcgee Posted October 18, 2006 Share Posted October 18, 2006 Wow, that's so awesome! I like the squishy . - Dan [Website] Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 19, 2006 Author Share Posted October 19, 2006 this is what i meant...not perfected... just added to your original scripti think you can see the direction for an interchangeable control-ID, thus a UDF8)Cool, thanks for the tip. Couldn't do any more than read it today, haven't been in the same room with a Windows box all day (so it's been a GOOD day!). I'll try it out as soon as I get a chance. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 19, 2006 Share Posted October 19, 2006 Heh. That's something I havn't seen done before. Cool. Link to comment Share on other sites More sharing options...
_Kurt Posted October 19, 2006 Share Posted October 19, 2006 Nice job, but like Valuator said, make it more of a UDF. Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
NELyon Posted October 21, 2006 Share Posted October 21, 2006 I tried to integrate this into my shell program, and it runs really slow. (Not the shell, the button)Was this one of those Copy/Paste issues i have? Or is it because XSkin is in use?CODE#include <XSkin.au3>#Include <GUIConstants.au3>#Include <IE.au3>Global $ButtonX = $pos[0], $ButtonY = $pos[1], $ButtonW = 60, $ButtonH = 40Global $aProgDat[3] = [0, 1, 0] ; [0]=Offset, [1]=Direction, [2]=SquishHotKeySet("^x", "exito")$oIE = _IECreateEmbedded()Opt("WinTitleMatchMode", 4)$handle = WinGetHandle("classname=Shell_TrayWnd")WinSetState ( $handle, "", @sw_hide ); the two following folders are seperate for building skins; however in YOUR program put them in the same folder; folder of skin$Skin_Folder = @ScriptDir & "\Silent-green"; icon folder$Icon_Folder = @ScriptDir & "SkinsDefault"XSkinGUICreate("Test", 1108, 758, $Skin_Folder)$Shell = GUICtrlCreateIcon("shell32.dll", 94, 50, 50)$Shelll = GUICtrlCreateLabel("Run Normal Shell", 50, 90)$B = GUICtrlCreateButton("START", $ButtonX, $ButtonY, $ButtonW, $ButtonH)GUISetState()AdlibEnable("_UpdateProg")While 1 $msg = GUIGetMsg() Switch $msg Case $Shell Run("explorer.exe") EndSwitchWEndFunc OnAutoitExit()WinSetState ( $handle, "", @SW_SHOW )EndFuncFunc Exito() ExitEndFuncFunc _UpdateProg() If $aProgDat[2] = 0 Then $aProgDat[0] += $aProgDat[1] If $aProgDat[0] >= 5 Then ; Hit bottom $aProgDat[0] = 5 ; stop offset $aProgDat[2] += $aProgDat[1] ; Increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = -1 EndIf ElseIf $aProgDat[0] <= -5 Then ; Hit top $aProgDat[0] = -5 ; stop offset $aProgDat[2] -= $aProgDat[1] ; increment squish If $aProgDat[2] > 5 Then ; Squish 0 thru 5 then reverse direction ; Max squish $aProgDat[2] = 5 ; Reverse direction $aProgDat[1] = 1 EndIf EndIf ; Move button $NewY = $ButtonY + $aProgDat[0] ; Apply squishiness to button height $NewH = $ButtonH If $aProgDat[0] = 5 Then $NewY += $aProgDat[2] $NewH -= $aProgDat[2] ElseIf $aProgDat[0] = -5 Then $NewH -= $aProgDat[2] EndIf GUICtrlSetPos($B, $ButtonX, $NewY, $ButtonW, $NewH) ; Change pos to offset and squishinessEndFunc ;==>_UpdateProg Link to comment Share on other sites More sharing options...
the DtTvB Posted October 21, 2006 Share Posted October 21, 2006 It's quite cool. And I knew nothing about Adlib. This is new knowledge to me, thank you. What about this code? I think it's a bit smoother. Func _UpdateProg() $aProgDat[0] += 0.3 GUICtrlSetPos($ButtonId, $ButtonX, $ButtonY + (sin($aProgDat[0]) * 5)) EndFunc ;==>_UpdateProg [right]Please visit: My biggest project, the DtTvB's AutoIt Web ServerOlder Stuff: A Smoother MouseMove :: AutoIt Syntax Highlighter[/right] 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