Jump to content

Recommended Posts

Posted (edited)

Is there anyway I can run this loop or something similar
 

Func _work()
    Local $i = 0
    Do
        Send("{MEDIA_NEXT down}")
        Send("{MEDIA_NEXT up}")
        Sleep(60000)
        $i = $i + 1
    Until $i =60

in this code here?

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>


Global $_CompteArebour = 0, $_Hours, $_Minutes, $_Seconds
$TimeTicks = TimerInit()

$Form1 = GUICreate("Power Hour", 946, 535, -1, -1, BitOR($WS_BORDER, $WS_BORDER))
GUISetBkColor(0x363636)
$TimerLabel = GUICtrlCreateLabel("", 145, 125, 647, 125, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", $_Hours, $_Minutes, $_Seconds))
GUICtrlSetFont($TimerLabel, 125, 400, 0, "Digital Readout Thick")
#Region --- CodeWizard generated code Start ---
GUICtrlSetColor($TimerLabel, 0xFF0000)
#EndRegion --- CodeWizard generated code Start ---
$BtnStart = GUICtrlCreateButton("Start", 200, 298, 250, 83)
$BtnPause = GUICtrlCreateButton("Pause", 200, 298, 250, 83)
$BtnReset = GUICtrlCreateButton("Reset", 490, 298, 250, 83)
$BtnAdd60 = GUICtrlCreateButton("60", 200, 400, 121.5, 53)
$BtnAdd100 = GUICtrlCreateButton("100", 330, 400, 121.5, 53)
$BtnAdd120 = GUICtrlCreateButton("120", 490, 400, 121.5, 53)
$BtnAdd180 = GUICtrlCreateButton("180", 620, 400, 121.5, 53)
GUICtrlSetColor($BtnStart, 0x81B71A)
GUICtrlSetBkColor($BtnStart, 0x303030)
GUICtrlSetBkColor($BtnPause, 0x303030)
GUICtrlSetColor($BtnPause, 0x81B71A)
GUICtrlSetBkColor($BtnAdd60, 0x303030)
GUICtrlSetColor($BtnAdd60, 0x81B71A)
GUICtrlSetBkColor($BtnAdd100, 0x303030)
GUICtrlSetColor($BtnAdd100, 0x81B71A)
GUICtrlSetBkColor($BtnAdd120, 0x303030)
GUICtrlSetColor($BtnAdd120, 0x81B71A)
GUICtrlSetBkColor($BtnAdd180, 0x303030)
GUICtrlSetColor($BtnAdd180, 0x81B71A)
GUICtrlSetBkColor($BtnReset, 0x303030)
GUICtrlSetColor($BtnReset, 0x81B71A)
GUISetState(@SW_SHOW)


HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $BtnStart ;<=== When pressed "Start", hide and then show "Pause"
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnAdd60 ;=== Add 1 hour to the Timer
            $_CompteArebour = $_CompteArebour + (60000 * 60)
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnAdd100 ;=== Add 100 minutes to the Timer
            $_CompteArebour = $_CompteArebour + (100000 * 60)
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnAdd120 ;=== Add 2 hours to the Timer
            $_CompteArebour = $_CompteArebour + (120000 * 60)
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnAdd180 ;=== Add 3 hours to the Timer
            $_CompteArebour = $_CompteArebour + (180000 * 60)
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnReset ;=== Reset the Timer to 00:00(doesn't work)
            $_CompteArebour = 3600000
            _Run()
            GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", 0, 0, 0))
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func _Run()
    While 1
        _Check()
    WEnd
EndFunc   ;==>_Run

Func _Check() ;==> A function I took from an other example hoping to get an input to work
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $BtnStart ;<=== When pressed "Start", hide and then show "Pause"
            GUICtrlSetState($BtnStart, $GUI_HIDE)
            GUICtrlSetState($BtnPause, $GUI_SHOW)
            _Run()
        Case $BtnPause ;<=== When pressed "Pause" hide and then show "Start"
            GUICtrlSetState($BtnPause, $GUI_HIDE)
            GUICtrlSetState($BtnStart, $GUI_SHOW)
        Case $BtnAdd60 ;=== Add 1 hour to the Timer
            $_CompteArebour = $_CompteArebour + 3600000
        Case $BtnAdd100 ;=== Add 100 minutes to the Timer
            $_CompteArebour = $_CompteArebour + 6000000
        Case $BtnAdd120 ;=== Add 2 hours to the Timer
            $_CompteArebour = $_CompteArebour + 7200000
        Case $BtnAdd180 ;=== Add 3 hours to the Timer
            $_CompteArebour = $_CompteArebour + 10800000
        Case $BtnReset ;=== Reset the Timer to 00:00
            $_CompteArebour = 3600000
            _Run()
            GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", $_Hours, $_Minutes, $_Seconds))
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

    $_CompteArebour -= TimerDiff($TimeTicks)
    $TimeTicks = TimerInit()

    Local $_HourCalc = Int($_CompteArebour / 3600000)
    $_MinCalc = Int(($_CompteArebour - $_HourCalc * 3600000) / 60000)
    Sleep(200)
    $_SecCalc = $_CompteArebour / 1000 - ($_MinCalc * 60) - 3600 * $_HourCalc
    GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", $_Hours, $_Minutes, $_Seconds))
    If $_HourCalc <= 0 And $_MinCalc <= 0 And $_SecCalc <= 0 Then
        GUICtrlSetData($TimerLabel, "Power!")
        Sleep(1000)
        GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", $_Hours, $_Minutes, $_Seconds))
        ; If @Compiled Then Shutdown ( 13 )
    Else
        If $_HourCalc <> $_Hours Or $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then
            $_Hours = $_HourCalc
            $_Minutes = $_MinCalc
            $_Seconds = $_SecCalc
            GUICtrlSetData($TimerLabel, StringFormat("%02d" & ":" & "%02d" & ":" & "%02d", $_Hours, $_Minutes, $_Seconds))
            If $_Hours = 0 And $_Minutes = 0 And $_Seconds <= 10 Then
                Beep(1200, 100)
                GUISetBkColor(0xA093FF, $Form1)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_Check

Basically I want this script to run and every time it counts down a minute  it would hit the next key and change the song. I've read and read and tried a bunch of things. I'm sure I'm just doing something wrong but have no idea what.

Edited by Countryrunner
Accidentally posted wrong code
Posted

I finally figured out what I did wrong before when I tried AdlibRegister, I suck at spelling and did AddlibRegister. I also found a good example I was able to use to get it right. Thanks for pointing me in the right direction.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...