somdcomputerguy Posted June 13, 2009 Share Posted June 13, 2009 (edited) I've been working on and off on this script for the last few weeks, it does what I intended it for, so I'll just post the code here, to 'share' it or something.. I'm sure some serious coders here will laugh a bit thinking 'why the hell is he doing that like that', but maybe it'll help out another new coder.. I don't really have any questions about it, I know this isn't the right category to ask questions in anyway, but a few things really had me scratching my head. Just about all the obstacles I had were overcome by reading alot thru this forum, and reading the docs many many many times.. There's still some things I plan to do, but it works good for me now, so I'm taking a break from it..expandcollapse popup#include <Date.au3> #include <String.au3> #include <Array.au3> #include <Winamp_Library.au3> #include <SliderConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global $Form2, $CountdownTotal, $Countdown, $CurrentVolume, $Radio3, $Radio4, $Radio5, $Radio6, $Checkbox1, $Checkbox2, $Checkbox3, $Checkbox4, $Checkbox5, $Checkbox6, $Checkbox7, $Checkbox8, $Checkbox9, $Input1, $Input2, $Input3, $Input4, $Input5, $Combo1, $Combo2, $Button1, $Button2, $Button3, $Group1, $Group2, $Slider1, $Slider1_Value, $Old_Slider1_Value, $Slider2, $Slider2_Value, $Old_Slider2_Value, $Progressbar1, $Progressbar1_Countdown, $Progressbar2, $Time_Array, $Date_Array, $iDateDiff, $iDateDiffTotal, $Tab, $Tab0, $Tab1 #Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\koda\Forms\LoremIpsum.kxf $Form2 = GUICreate("X-Lorem Ipsum", 450, 290, 175, 310) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $Tab = GUICtrlCreateTab(-1, -1, 450, 290) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Tab0 = GUICtrlCreateTabItem("Countdown") ;$Tab0 = _GUICtrlTab_InsertItem($Tab, 0, "Countdown") $Checkbox6 = GUICtrlCreateCheckbox("WinAmp", 80, 40, 73, 17) $Checkbox7 = GUICtrlCreateCheckbox("HAVA", 165, 40, 57, 17) $Input1 = GUICtrlCreateInput("3.5", 100, 205, 30, 20) $Combo1 = GUICtrlCreateCombo("Time Frame", 150, 205, 90, 25) GUICtrlSetData(-1, "Hour|Minute") $Input2 = GUICtrlCreateInput("Time", 250, 205, 50, 20, $ES_CENTER) $Combo2 = GUICtrlCreateCombo("Select", 200, 85, 90, 25) GUICtrlSetData(-1, "Standby|Hibernate") GUICtrlCreateLabel("Shutdown", 190, 70) $Checkbox1 = GUICtrlCreateCheckbox("VZAccess", 240, 40, 80, 15) $Checkbox2 = GUICtrlCreateCheckbox("Just Stop", 85, 70, 80, 15) $Checkbox3 = GUICtrlCreateCheckbox("After Current", 85, 90, 80, 15) $Progressbar1 = GUICtrlCreateProgress(45, 175, 335, 22, -1, $PBS_SMOOTH) GUICtrlSetColor($Progressbar1, 0x0A246A) $Button1 = GUICtrlCreateButton("Begin", 80, 240, 280, 25, $WS_GROUP) GUICtrlSetOnEvent($Button1, "Lullaby") $Tab1 = GUICtrlCreateTabItem("Alarm") ;$Tab1 = _GUICtrlTab_InsertItem($Tab, 1, "Alarm") $Checkbox8 = GUICtrlCreateCheckbox("WinAmp", 80, 40, 73, 17) $Checkbox9 = GUICtrlCreateCheckbox("HAVA", 160, 40, 73, 17) ;$Input2 = GUICtrlCreateInput("", 45, 175, 335, 22, $ES_READONLY + $ES_CENTER) $Progressbar2 = GUICtrlCreateProgress(45, 175, 335, 22, -1, $PBS_SMOOTH) GUICtrlSetColor($Progressbar2, 0x0A246A) $Input3 = GUICtrlCreateInput(@HOUR & ":" & @MIN, 230, 205, 50, 20, $ES_CENTER) $Input4 = GUICtrlCreateInput(@MON & "/" & @MDAY, 155, 205, 50, 20, $ES_CENTER) GUICtrlCreateLabel("Alarm Time", 80, 210) $Slider1 = GUICtrlCreateSlider(110, 110, 200, 20) GUICtrlCreateLabel("Fade In Time", 35, 110) GUICtrlSetOnEvent($Slider1, "Update_FadeInTime") GUICtrlSetLimit(-1, 20, 0) GUICtrlSetData($Slider1, 5) $Slider2 = GUICtrlCreateSlider(110, 140, 200, 20) GUICtrlCreateLabel("Max Volume", 35, 140) GUICtrlSetOnEvent($Slider2, "Update_MaxVolume") GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData($Slider2, 85) $Button2 = GUICtrlCreateButton("Start", 80, 240, 280, 25, $WS_GROUP) GUICtrlSetOnEvent($Button2, "Lullaby") $Slider1_Value = GUICtrlCreateLabel(GUICtrlRead($Slider1), 325, 110) $Slider2_Value = GUICtrlCreateLabel(GUICtrlRead($Slider2), 325, 140) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(1000) WEnd Func Lullaby() ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 5, 10) ;_GUICtrlTab_SetCurSel($Tab, 0) If GUICtrlRead($Combo1) <> "Time Frame" Then Switch GUICtrlRead($Combo1) Case "Hour" $Countdown = GUICtrlRead($Input1) * 3600000 $CountdownTotal = $Countdown Case "Minute" $Countdown = GUICtrlRead($Input1) * 60000 $CountdownTotal = $Countdown EndSwitch Do GUICtrlSetData($Progressbar1, ($Countdown / $CountdownTotal) * 100) Sleep(1000) ToolTip(Round(($Countdown / $CountdownTotal) * 100) & "% : " & $Countdown / 1000 & " seconds") $Countdown = $Countdown - 1000 Until $Countdown <= 0 ToolTip("") GUICtrlSetData($Progressbar1, 0) If GUICtrlRead($Checkbox6) = 1 Then If GUICtrlRead($Checkbox2) = 1 Then Send("^!v") If GUICtrlRead($Checkbox3) = 1 Then WinActivate("Player Window") Sleep(50) Send("^v") EndIf EndIf If GUICtrlRead($Checkbox1) = 1 Then ControlClick("VZAccess Manager", "", "ToolbarWindow324", "left", "1", 40, 20) If GUICtrlRead($Checkbox7) = 1 Then ControlClick("HAVA PC Player", "", "EMZBUTTON28") EndIf Sleep(5000) If GUICtrlRead($Combo2) <> "Select" Then Switch GUICtrlRead($Combo2) Case "Standby" Shutdown(32) Case "Hibernate" Shutdown(64) EndSwitch EndIf Wakeup() EndFunc Func Wakeup() ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 90, 10) ;_GUICtrlTab_SetCurSel($Tab, 1) $Time_Array = StringSplit(GUICtrlRead($Input3), ':') $Date_Array = StringSplit(GUICtrlRead($Input4), '/') $iDateDiffTotal = _DateDiff('s',_NowCalc(), @YEAR & "/" & $Date_Array[1] & "/" & $Date_Array[2] & " " & $Time_Array[1] & ":" & $Time_Array[2] & ":" & @SEC) Do $iDateDiff = _DateDiff('s', _NowCalc(), @YEAR & "/" & $Date_Array[1] & "/" & $Date_Array[2] & " " & $Time_Array[1] & ":" & $Time_Array[2] & ":" & @SEC) ToolTip(Round(($iDateDiff / $iDateDiffTotal) * 100) & "% : " & $iDateDiff) GUICtrlSetData($Progressbar2, ($iDateDiff / $iDateDiffTotal) * 100) If GUICtrlRead($Input3) = _NowTime(4) Then If GUICtrlRead($Checkbox8) = 1 Then If Not ProcessExists("winamp.exe") Then Run("C:\Program Files\winamp\winamp.exe") Sleep(15000) EndIf Send("^!x") Fadein(GUICtrlRead($Slider1), GUICtrlRead($Slider2)) EndIf If GUICtrlRead($Checkbox9) = 1 Then Run("C:\Program Files\Monsoon Multimedia\HAVA\PC Player\HAVA PC Player.exe") EndIf Until GUICtrlRead($Input3) = _NowTime(4) ToolTip("") EndFunc Func Fadein($FadeTime, $MaxVolume) If GUICtrlRead($Checkbox8) = 1 Then Run("sndvol.exe", "", @SW_HIDE) WinWaitActive("Volume Mixer") Send("{HOME}") WinClose("Volume Mixer") EndIf If $FadeTime <= 0 Then $FadeTime = .1 _Winamp_SetVolume(0) Do _Winamp_SetVolume(-1, 1) Sleep($FadeTime * 50) $CurrentVolume = _Winamp_GetVolume() Until $CurrentVolume / 255 * 100 >= $MaxVolume EndFunc Func Update_FadeInTime() If GUICtrlRead($Slider1) <> $Old_Slider1_Value Then GUICtrlSetData($Slider1_Value, GUICtrlRead($Slider1)) $Old_Slider1_Value = GUICtrlRead($Slider1) EndIf EndFunc Func Update_MaxVolume() If GUICtrlRead($Slider2) <> $Old_Slider2_Value Then GUICtrlSetData($Slider2_Value, GUICtrlRead($Slider2)) $Old_Slider2_Value = GUICtrlRead($Slider2) EndIf EndFunc Func Close() Exit EndFuncBTW, the input field on the 'Countdown' tab that says 'Time' doesn't do anything yet, but what I plan on eventually doing is adding the abilty to either countdown specified minutes or hours, or countdown to a specific time..If anybody uses this code and it benefits you somehow, super.BruceEdit: I have to add thanks to MrCreatoR for creating the Winamp Library, which kept me having to use all kinds of mousedrags and sends.. and also BrettF for a post (in another thread, but related to an issue I was stuck by), (Given amount/ Total amount)*100. There were many other posts made here that helped me quite a bit, so thanks to all. Oh yeah, I edited my posted code this earlier morning to fix the fade time and max vol updates.. Edited June 14, 2009 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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