Sign in to follow this  
Followers 0
Golbez

i need help!

7 posts in this topic

2 things

1st. how in the gui would i make it so on the setup gui and they are on the hot keys. how could i make it so when the user click on an input box they press the keys that are there hotkeys for winamp and it automaticly puts in what they are pressing.

2nd. when the code does this:

IniWrite("alarm.ini", "other", "closewinamp", $Checkbox1)
                IniWrite("alarm.ini", "other", "closescript", $Checkbox2)

it only gives 1 value even if the box is checked or not.. how do i fix this or a clue tward it plz xD

Opt('GUIONEVENTMODE', 1)
#include <Date.au3>
#include <GUIConstants.au3>
    
Global $stop, $play, $voldn, $volup, $next, $previous, $Setup, $close, $main, $iHour, $AMPM
Global $Button1, $Button2, $Button21, $Button3, $Button4, $Button9, $Button10, $Button11, $Button12, $iCHK, $iPid, $iCTime, $closescript, $playscript
Global $SleepHour, $SleepMinutes, $SleepTime, $SleepSeconds, $WakeHour, $WakeMinutes, $WakeSeconds, $WakeTime
_iniread()
_MainGUI()

Func _MainGUI()
    $Main = GUICreate("Golbez Alarm", 274, 218, 352, 257, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
        GUISetBkColor(0xA0A0A4)
    $iCTime = GUICtrlCreateLabel('Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM _ 
        , 25, 10, 80, 37, 0x01, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    $Button1 = GUICtrlCreateButton("Exit", 192, 176, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 7)
        GUICtrlSetOnEvent(-1, "Terminate")
    $Button2 = GUICtrlCreateButton("Setup", 192, 136, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUISetOnEvent(-3, 'Terminate')
        GUICtrlSetOnEvent($Button2, '_MAINEVENTS')
        GUISetState()
    $Button3 = GUICtrlCreateButton("Play", 144, 136, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays current song.")
        GUICtrlSetOnEvent(-1, "Play")
    $Button4 = GUICtrlCreateButton("Stop", 144, 176, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Stops current song.")
        GUICtrlSetOnEvent(-1, "Stop")
    $Button9 = GUICtrlCreateButton("Previous", 8, 176, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays previous song.")
        GUICtrlSetOnEvent(-1, "_Previous")
    $Button10 = GUICtrlCreateButton("Next", 8, 136, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays next song.")
        GUICtrlSetOnEvent(-1, "_Next")
    $Button11 = GUICtrlCreateButton("Vol Up", 80, 136, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume up.")
        GUICtrlSetOnEvent(-1, "VolUp")
    $Button12 = GUICtrlCreateButton("Vol Dn", 80, 176, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume down.")
        GUICtrlSetOnEvent(-1, "VolDown")
    $Button13 = GUICtrlCreateButton("Snooze", 120, 8, 145, 41, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $SleepHour = GUICtrlCreateCombo("Hour", 24, 64, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $SleepMinutes = GUICtrlCreateCombo("Minutes", 72, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepSeconds = GUICtrlCreateCombo("Seconds", 136, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepTime = GUICtrlCreateCombo("Time", 208, 64, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $WakeHour = GUICtrlCreateCombo("Hour", 26, 104, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $WakeMinutes = GUICtrlCreateCombo("Minutes", 74, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeSeconds = GUICtrlCreateCombo("Seconds", 138, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeTime = GUICtrlCreateCombo("Time", 210, 104, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $Group1 = GUICtrlCreateGroup("Sleep Time", 16, 48, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Wake Up Time", 16, 88, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate", $Main)
    While 1
        Sleep(1000)
        _AdlibManager()
    WEnd
EndFunc
Func _AdlibManager()
    Local $aSplit = StringSplit(GUICtrlRead($iCTime), ':')
    If $aSplit[0] >= 3 And (Int($aSplit[1]) >= _GetHour(@HOUR) _
        Or Int($aSplit[2]) >= @MIN Or Int(StringTrimRight($aSplit[3], 3)) > @SEC) Then _
        GUICtrlSetData($iCTime, 'Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM)
   
    If @HOUR = _SwitchHour(GUICtrlRead($SleepHour)) And @MIN = GUICtrlRead($SleepMinutes) And _
        $AMPM = GUICtrlRead($SleepTime) And @SEC = GUICtrlRead($SleepSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        SleepTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
    If @HOUR = _SwitchHour(GUICtrlRead($WakeHour)) And @MIN = GUICtrlRead($WakeMinutes) And _
        $AMPM = GUICtrlRead($WakeTime) And @SEC = GUICtrlRead($WakeSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        PlayTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
EndFunc
Func _MAINEVENTS()
    Switch @GUI_CtrlId
        Case $Button2
            GUISetState(@SW_HIDE, HWnd($Main))
            Opt('GUIONEVENTMODE', _SetupGUI())
            GUISetState(@SW_SHOW, HWnd($Main))
    EndSwitch
EndFunc
Func _SetupGUI()
    $OptGOEM = Opt('GUIONEVENTMODE', 0)
    $Setup = GUICreate("Setup", 273, 217, 353, 257)
        GUISetFont(8, 400, 0, "Comic Sans MS")
    $Label1 = GUICtrlCreateLabel("", 24, 0, 4, 4)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button21 = GUICtrlCreateButton("Back to Main Menu", 128, 176, 129, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button1 = GUICtrlCreateButton("Accept", 16, 176, 81, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabMenu = GUICtrlCreateTab(0, 8, 265, 161)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet1 = GUICtrlCreateTabItem("Other")
    $Group1 = GUICtrlCreateGroup("Snooze Time", 8, 51, 97, 47, $BS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Checkbox1 = GUICtrlCreateCheckbox("Close Winamp after alarm is triggered", 8, 107, 241, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Checkbox2 = GUICtrlCreateCheckbox("Close Alarm after alarm is triggered", 8, 139, 233, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $SnoozeTime = GUICtrlCreateCombo("Minutes", 16, 67, 81, 25)
        GUICtrlSetData(-1, "05|10|15|20|25|30")
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet2 = GUICtrlCreateTabItem("Keystrokes")
    $TabSheet3 = GUICtrlCreateTabItem("")
    $TabSheet4 = GUICtrlCreateTabItem("")
    $TabSheet5 = GUICtrlCreateTabItem("About")
        GUICtrlSetState(-1,$GUI_SHOW)
    $Label3 = GUICtrlCreateLabel("Made By: Ray Smith", 140, 41, 106, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label2 = GUICtrlCreateLabel("Thanks", 148, 58, 40, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label4 = GUICtrlCreateLabel("Smoke", 160, 76, 38, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label5 = GUICtrlCreateLabel("Prodigy", 160, 92, 43, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label6 = GUICtrlCreateLabel("BB_HIT_MAN", 160, 108, 80, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label7 = GUICtrlCreateLabel("Version:  1.04", 174, 138, 74, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Pic1 = GUICtrlCreatePic("Pic1.gif", 0, 40, 140, 114, 0, $GUI_WS_EX_PARENTDRAG)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case - 3
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button21
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button1 
                IniWrite("alarm.ini", "time", "sleep", $SnoozeTime * 1000)
                IniWrite("alarm.ini", "other", "closewinamp", $Checkbox1)
                IniWrite("alarm.ini", "other", "closescript", $Checkbox2)
                IniWrite("alarm.ini", "hotkeys", "play", "")
                IniWrite("alarm.ini", "hotkeys", "stop", "")
                IniWrite("alarm.ini", "hotkeys", "pause", "")
                IniWrite("alarm.ini", "hotkeys", "volup", "")
                IniWrite("alarm.ini", "hotkeys", "voldn", "")
                IniWrite("alarm.ini", "hotkeys", "next", "")
                IniWrite("alarm.ini", "hotkeys", "previous", "")
        EndSwitch
    WEnd
EndFunc
Func _iniread()
;Other
    $timekey = "{del}"
    $endkey = "{end}"
    HotKeySet($endkey, "Terminate")
    HotKeySet($timekey, "GetTime")
    $closewinamp = IniRead ("alarm.ini", "other", "closewinamp", "0")
    $closescript = IniRead ("alarm.ini", "other", "closescript", "0")
;Delays
    $sleep = IniRead ("alarm.ini", "time", "sleep", "00")
    
;Keys
    $play = IniRead ("alarm.ini", "hotkeys", "play", "^!{ins}")
    $stop = IniRead ("alarm.ini", "hotkeys", "stop", "^!{end}")
    $pause = IniRead ("alarm.ini", "hotkeys", "pause", "^!{home}")
    $volup = IniRead ("alarm.ini", "hotkeys", "volup", "^!{up}")
    $voldn = IniRead ("alarm.ini", "hotkeys", "voldn", "^!{down}")
    $next = IniRead ("alarm.ini", "hotkeys", "next", "^!{left}")
    $previous = IniRead ("alarm.ini", "hotkeys", "previous", "^!{right}")
EndFunc
Func _GetHour($iHour)
    Switch $iHour
        Case 12
            $AMPM = 'PM'
            Return $iHour
        Case 13 To 23
            $AMPM = 'PM'
            Return $iHour - 12
        Case 0
            $AMPM = 'AM'
            Return 12
        Case 1 To 11
            $AMPM = 'AM'
            Return $iHour
    EndSwitch
EndFunc
Func _SwitchHour($iHour)
    Switch $iHour
        Case 12
            If $AMPM = 'AM' Then
                Return 0
            Else
                Return 12
            EndIf
        Case 1 To 11
            If $AMPM = 'PM' Then
                Return $iHour + 12
            Else
                Return $iHour
            EndIf
    EndSwitch
EndFunc
Func GetTime()
    MsgBox(48,"time", "hour is: " & @HOUR & " min is: " & @MIN & " sec is: " & @SEC, 5)
    MsgBox(48,"date", "month is: " & @MON & " day is: " & @WDAY & " year is: " & @YEAR, 5)
EndFunc
Func SleepTime()
    Stop()
   ;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func PlayTime()
    Play()
   ;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func Play()
    Send($play)
EndFunc
Func Stop()
    Send($stop)
EndFunc
Func VolUp()
    Send($volup)
EndFunc
Func VolDown()
    Send($voldn)
EndFunc
Func _Next()
    Send($next)
EndFunc
Func _Previous()
    Send($previous)
EndFunc
Func Terminate()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



1. Try altering their Ini before you start WinAmp

enabled=1

action0=ghkdc play

hotkey0=3629

action1=ghkdc pause

hotkey1=3620

action2=ghkdc stop

hotkey2=3619

action3=ghkdc prev

hotkey3=3617

action4=ghkdc next

hotkey4=3618

action5=ghkdc vup

hotkey5=3622

action6=ghkdc vdown

hotkey6=3624

action7=ghkdc forward

hotkey7=3623

action8=ghkdc rewind

hotkey8=3621

action9=ghkdc jump

hotkey9=3658

action10=ghkdc file

hotkey10=3660

action11=ghkdc stop

hotkey11=2226

action12=ghkdc play/pause

hotkey12=2227

action13=ghkdc prev

hotkey13=2225

action14=ghkdc next

hotkey14=2224

2. Use GUICtrlRead($CheckBox1)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yeah i no i could do it that way but i wanna make it so the global hotkeys that they could set in winamp they also set in my alarm.

then have the alarm send the stored info to winamp threw the global hotkey

codeupdate:

Opt('GUIONEVENTMODE', 1)
#include <Date.au3>
#include <GUIConstants.au3>
    
Global $stop, $play, $voldn, $volup, $next, $previous, $Setup, $close, $main, $iHour, $AMPM, $sleep, $pause
Global $Button1, $Button2, $Button21, $Button3, $Button4, $Button9, $Button10, $Button11, $Button12, $iCHK, $iPid, $iCTime, $closescript, $playscript
Global $SleepHour, $SleepMinutes, $SleepTime, $SleepSeconds, $WakeHour, $WakeMinutes, $WakeSeconds, $WakeTime

_MainGUI()

Func _MainGUI()
    _iniread()
    $Main = GUICreate("Golbez Alarm", 274, 218, 352, 257, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
        GUISetBkColor(0xA0A0A4)
    $iCTime = GUICtrlCreateLabel('Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM _ 
        , 25, 10, 80, 37, 0x01, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    $Button1 = GUICtrlCreateButton("Exit", 192, 176, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 7)
        GUICtrlSetOnEvent(-1, "Terminate")
    $Button2 = GUICtrlCreateButton("Setup", 192, 136, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUISetOnEvent(-3, 'Terminate')
        GUICtrlSetOnEvent($Button2, '_MAINEVENTS')
        GUISetState()
    $Button3 = GUICtrlCreateButton("Play", 144, 136, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays current song.")
        GUICtrlSetOnEvent(-1, "Play")
    $Button4 = GUICtrlCreateButton("Stop", 144, 176, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Stops current song.")
        GUICtrlSetOnEvent(-1, "Stop")
    $Button9 = GUICtrlCreateButton("Previous", 8, 176, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays previous song.")
        GUICtrlSetOnEvent(-1, "_Previous")
    $Button10 = GUICtrlCreateButton("Next", 8, 136, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays next song.")
        GUICtrlSetOnEvent(-1, "_Next")
    $Button11 = GUICtrlCreateButton("Vol Up", 80, 136, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume up.")
        GUICtrlSetOnEvent(-1, "VolUp")
    $Button12 = GUICtrlCreateButton("Vol Dn", 80, 176, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume down.")
        GUICtrlSetOnEvent(-1, "VolDown")
    $Button13 = GUICtrlCreateButton("Snooze", 120, 8, 145, 41, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Pauses alarm for: " & $sleep / 1000 & " minutes.")
        GUICtrlSetOnEvent(-1, "_Snooze")
    $SleepHour = GUICtrlCreateCombo("Hour", 24, 64, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $SleepMinutes = GUICtrlCreateCombo("Minutes", 72, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepSeconds = GUICtrlCreateCombo("Seconds", 136, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepTime = GUICtrlCreateCombo("Time", 208, 64, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $WakeHour = GUICtrlCreateCombo("Hour", 26, 104, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $WakeMinutes = GUICtrlCreateCombo("Minutes", 74, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeSeconds = GUICtrlCreateCombo("Seconds", 138, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeTime = GUICtrlCreateCombo("Time", 210, 104, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $Group1 = GUICtrlCreateGroup("Sleep Time", 16, 48, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Wake Up Time", 16, 88, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate", $Main)
    While 1
        Sleep(1000)
        _AdlibManager()
    WEnd
EndFunc
Func _AdlibManager()
    Local $aSplit = StringSplit(GUICtrlRead($iCTime), ':')
    If $aSplit[0] >= 3 And (Int($aSplit[1]) >= _GetHour(@HOUR) _
        Or Int($aSplit[2]) >= @MIN Or Int(StringTrimRight($aSplit[3], 3)) > @SEC) Then _
        GUICtrlSetData($iCTime, 'Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM)
   
    If @HOUR = _SwitchHour(GUICtrlRead($SleepHour)) And @MIN = GUICtrlRead($SleepMinutes) And _
        $AMPM = GUICtrlRead($SleepTime) And @SEC = GUICtrlRead($SleepSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        SleepTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
    If @HOUR = _SwitchHour(GUICtrlRead($WakeHour)) And @MIN = GUICtrlRead($WakeMinutes) And _
        $AMPM = GUICtrlRead($WakeTime) And @SEC = GUICtrlRead($WakeSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        PlayTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
EndFunc
Func _MAINEVENTS()
    Switch @GUI_CtrlId
        Case $Button2
            GUISetState(@SW_HIDE, HWnd($Main))
            Opt('GUIONEVENTMODE', _SetupGUI())
            GUISetState(@SW_SHOW, HWnd($Main))
    EndSwitch
EndFunc
Func _SetupGUI()
    $OptGOEM = Opt('GUIONEVENTMODE', 0)
    $Setup = GUICreate("Setup", 273, 217, 353, 257)
        GUISetFont(8, 400, 0, "Comic Sans MS")
    $Label1 = GUICtrlCreateLabel("", 24, 0, 4, 4)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button21 = GUICtrlCreateButton("Back to Main Menu", 128, 176, 129, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button1 = GUICtrlCreateButton("Accept", 16, 176, 81, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabMenu = GUICtrlCreateTab(0, 8, 265, 161)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet1 = GUICtrlCreateTabItem("Other")
    $Group1 = GUICtrlCreateGroup("Snooze Time", 8, 51, 97, 47, $BS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Checkbox1 = GUICtrlCreateCheckbox("Close Winamp after alarm is triggered", 8, 107, 241, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Checkbox2 = GUICtrlCreateCheckbox("Close Alarm after alarm is triggered", 8, 139, 233, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $SnoozeTime = GUICtrlCreateCombo("Minutes", 16, 67, 81, 25)
        GUICtrlSetData(-1, "05|10|15|20|25|30")
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet2 = GUICtrlCreateTabItem("Keystrokes")
    $TabSheet3 = GUICtrlCreateTabItem("")
    $TabSheet4 = GUICtrlCreateTabItem("")
    $TabSheet5 = GUICtrlCreateTabItem("About")
        GUICtrlSetState(-1,$GUI_SHOW)
    $Label3 = GUICtrlCreateLabel("Made By: Ray Smith", 140, 41, 106, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label2 = GUICtrlCreateLabel("Thanks", 148, 58, 40, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label4 = GUICtrlCreateLabel("Smoke", 160, 76, 38, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label5 = GUICtrlCreateLabel("Prodigy", 160, 92, 43, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label6 = GUICtrlCreateLabel("BB_HIT_MAN", 160, 108, 80, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label7 = GUICtrlCreateLabel("Version:  1.04", 174, 138, 74, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Pic1 = GUICtrlCreatePic("Pic1.gif", 0, 40, 140, 114, 0, $GUI_WS_EX_PARENTDRAG)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case - 3
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button21
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button1 
                IniWrite("alarm.ini", "time", "sleep", GUICtrlRead($SnoozeTime) * 1000)
                IniWrite("alarm.ini", "other", "closewinamp", GUICtrlRead($CheckBox1))
                IniWrite("alarm.ini", "other", "closescript", GUICtrlRead($CheckBox2))
                IniWrite("alarm.ini", "hotkeys", "play", "")
                IniWrite("alarm.ini", "hotkeys", "stop", "")
                IniWrite("alarm.ini", "hotkeys", "pause", "")
                IniWrite("alarm.ini", "hotkeys", "volup", "")
                IniWrite("alarm.ini", "hotkeys", "voldn", "")
                IniWrite("alarm.ini", "hotkeys", "next", "")
                IniWrite("alarm.ini", "hotkeys", "previous", "")
                IniWrite("alarm.ini", "hotkeys", "snooze", "")
        EndSwitch
    WEnd
EndFunc
Func _iniread()
;Other
    $endkey = "{end}"
    $closewinamp = IniRead ("alarm.ini", "other", "closewinamp", "4")
    $closescript = IniRead ("alarm.ini", "other", "closescript", "4")
;Delays
    $sleep = IniRead ("alarm.ini", "time", "sleep", "00")
    
;Keys
    $play = IniRead ("alarm.ini", "hotkeys", "play", "^!{ins}")
    $stop = IniRead ("alarm.ini", "hotkeys", "stop", "^!{end}")
    $pause = IniRead ("alarm.ini", "hotkeys", "pause", "^!{home}")
    $volup = IniRead ("alarm.ini", "hotkeys", "volup", "^!{up}")
    $voldn = IniRead ("alarm.ini", "hotkeys", "voldn", "^!{down}")
    $next = IniRead ("alarm.ini", "hotkeys", "next", "^!{left}")
    $previous = IniRead ("alarm.ini", "hotkeys", "previous", "^!{right}")
    $snoozekey = IniRead ("alarm.ini", "hotkeys", "snooze", "{space}")
    
        HotKeySet($snoozekey, "_Snooze")
        HotKeySet($endkey, "Terminate")
EndFunc
Func _GetHour($iHour)
    Switch $iHour
        Case 12
            $AMPM = 'PM'
            Return $iHour
        Case 13 To 23
            $AMPM = 'PM'
            Return $iHour - 12
        Case 0
            $AMPM = 'AM'
            Return 12
        Case 1 To 11
            $AMPM = 'AM'
            Return $iHour
    EndSwitch
EndFunc
Func _SwitchHour($iHour)
    Switch $iHour
        Case 12
            If $AMPM = 'AM' Then
                Return 0
            Else
                Return 12
            EndIf
        Case 1 To 11
            If $AMPM = 'PM' Then
                Return $iHour + 12
            Else
                Return $iHour
            EndIf
    EndSwitch
EndFunc
Func _Snooze()
    send($pause)
    Sleep($sleep)
    PlayTime()
EndFunc
Func SleepTime();
    Stop()
;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func PlayTime();
    Play()
;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func Play()
    Send($play)
EndFunc
Func Stop()
    Send($stop)
EndFunc
Func VolUp()
    Send($volup)
EndFunc
Func VolDown()
    Send($voldn)
EndFunc
Func _Next()
    Send($next)
EndFunc
Func _Previous()
    Send($previous)
EndFunc
Func Terminate()
    Exit
EndFunc
Edited by Golbez

Share this post


Link to post
Share on other sites

Errmmmm.... So set the ini valuesfor yourself and winamp :)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i did but i wanted 2 make it so the user does not have to go into the ini xD

come on smoke xD im tryen 2 make a good user friendly program :)

it all works atm but i wanted 2 make it so that the hotkeys can be changed in the ini :P

edit: i dont wanna take the easy way out :D

edit2: question how do i make it so if the box is checked it will reamber the box is checked.. in a sence i got this but it puts "1", it does not check the box again.

2 get the ini just open the setup and press apply. they go back to the main program.

Opt('GUIONEVENTMODE', 1)
#include <Date.au3>
#include <GUIConstants.au3>
    
Global $stop, $play, $voldn, $volup, $next, $previous, $Setup, $close, $main, $iHour, $AMPM, $sleep, $pause, $closewinamp, $closescript, $Checkbox1
Global $Button1, $Button2, $Button21, $Button3, $Button4, $Button9, $Button10, $Button11, $Button12, $iCHK, $iPid, $iCTime, $closescript, $playscript
Global $SleepHour, $SleepMinutes, $SleepTime, $SleepSeconds, $WakeHour, $WakeMinutes, $WakeSeconds, $WakeTime, $Checkbox2, $winampdir

_MainGUI()

Func _MainGUI()
    _iniread()
    $Main = GUICreate("Golbez Alarm", 274, 218, 352, 257, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
        GUISetBkColor(0xA0A0A4)
    $iCTime = GUICtrlCreateLabel('Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM _ 
        , 25, 10, 80, 37, 0x01, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    $Button1 = GUICtrlCreateButton("Exit", 192, 176, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetCursor ($Button1, 7)
        GUICtrlSetOnEvent(-1, "Terminate")
    $Button2 = GUICtrlCreateButton("Setup", 192, 136, 73, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUISetOnEvent(-3, 'Terminate')
        GUICtrlSetOnEvent($Button2, '_MAINEVENTS')
        GUISetState()
    $Button3 = GUICtrlCreateButton("Play", 144, 136, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays current song.")
        GUICtrlSetOnEvent(-1, "Play")
    $Button4 = GUICtrlCreateButton("Stop", 144, 176, 41, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Stops current song.")
        GUICtrlSetOnEvent(-1, "Stop")
    $Button9 = GUICtrlCreateButton("Previous", 8, 176, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays previous song.")
        GUICtrlSetOnEvent(-1, "_Previous")
    $Button10 = GUICtrlCreateButton("Next", 8, 136, 65, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Plays next song.")
        GUICtrlSetOnEvent(-1, "_Next")
    $Button11 = GUICtrlCreateButton("Vol Up", 80, 136, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume up.")
        GUICtrlSetOnEvent(-1, "VolUp")
    $Button12 = GUICtrlCreateButton("Vol Dn", 80, 176, 57, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Turn volume down.")
        GUICtrlSetOnEvent(-1, "VolDown")
    $Button13 = GUICtrlCreateButton("Snooze", 120, 8, 145, 41, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlSetTip(-1, "Pauses alarm for: " & $sleep / 1000 & " minutes.")
        GUICtrlSetOnEvent(-1, "_Snooze")
    $SleepHour = GUICtrlCreateCombo("Hour", 24, 64, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $SleepMinutes = GUICtrlCreateCombo("Minutes", 72, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepSeconds = GUICtrlCreateCombo("Seconds", 136, 64, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $SleepTime = GUICtrlCreateCombo("Time", 208, 64, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $WakeHour = GUICtrlCreateCombo("Hour", 26, 104, 49, 25)
        GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $WakeMinutes = GUICtrlCreateCombo("Minutes", 74, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeSeconds = GUICtrlCreateCombo("Seconds", 138, 104, 65, 25)
        GUICtrlSetData(-1, "00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $WakeTime = GUICtrlCreateCombo("Time", 210, 104, 49, 25)
        GUICtrlSetData(-1, "AM|PM")
    $Group1 = GUICtrlCreateGroup("Sleep Time", 16, 48, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Wake Up Time", 16, 88, 249, 41)
        GUICtrlSetBkColor(-1, 0xA0A0A4)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate", $Main)
    While 1
        Sleep(1000)
        _AdlibManager()
    WEnd
EndFunc
Func _AdlibManager()
    Local $aSplit = StringSplit(GUICtrlRead($iCTime), ':')
    If $aSplit[0] >= 3 And (Int($aSplit[1]) >= _GetHour(@HOUR) _
        Or Int($aSplit[2]) >= @MIN Or Int(StringTrimRight($aSplit[3], 3)) > @SEC) Then _
        GUICtrlSetData($iCTime, 'Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM)
   
    If @HOUR = _SwitchHour(GUICtrlRead($SleepHour)) And @MIN = GUICtrlRead($SleepMinutes) And _
        $AMPM = GUICtrlRead($SleepTime) And @SEC = GUICtrlRead($SleepSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        SleepTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
    If @HOUR = _SwitchHour(GUICtrlRead($WakeHour)) And @MIN = GUICtrlRead($WakeMinutes) And _
        $AMPM = GUICtrlRead($WakeTime) And @SEC = GUICtrlRead($WakeSeconds) Then; And BitAND(GUICtrlRead($iCHK[1]), 1) Then
        AdlibDisable()
        PlayTime()
        Sleep(500)
        ProcessClose($iPid)
        AdlibEnable('_AdlibManager', 100)
    EndIf
EndFunc
Func _MAINEVENTS()
    Switch @GUI_CtrlId
        Case $Button2
            GUISetState(@SW_HIDE, HWnd($Main))
            Opt('GUIONEVENTMODE', _SetupGUI())
            GUISetState(@SW_SHOW, HWnd($Main))
    EndSwitch
EndFunc
Func _SetupGUI()
    _iniread()
    $OptGOEM = Opt('GUIONEVENTMODE', 0)
    $Setup = GUICreate("Setup", 273, 217, 353, 257)
        GUISetFont(8, 400, 0, "Comic Sans MS")
    $Label1 = GUICtrlCreateLabel("", 24, 0, 4, 4)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button21 = GUICtrlCreateButton("Back to Main Menu", 128, 176, 129, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Button1 = GUICtrlCreateButton("Accept", 16, 176, 81, 33, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabMenu = GUICtrlCreateTab(0, 8, 265, 161)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet1 = GUICtrlCreateTabItem("Other")
    $Group1 = GUICtrlCreateGroup("Snooze Time", 8, 51, 97, 47, $BS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Checkbox1 = GUICtrlCreateCheckbox("Close Winamp after alarm is triggered", 8, 107, 241, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        If $closewinamp = 1 then GUICtrlSetData($Checkbox1, 1)
    $Checkbox2 = GUICtrlCreateCheckbox("Close Alarm after alarm is triggered", 8, 139, 233, 17)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        If $closescript = 1 then GUICtrlSetData($Checkbox2, 1)
    $SnoozeTime = GUICtrlCreateCombo("Minutes", 16, 67, 81, 25)
        GUICtrlSetData(-1, "05|10|15|20|25|30")
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
        If $sleep <> 0 then GUICtrlSetData($SnoozeTime, $sleep / 1000)
    $Button4 = GUICtrlCreateButton("Open Winamp", 120, 48, 129, 49, 0)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $TabSheet2 = GUICtrlCreateTabItem("Keystrokes")
    $TabSheet3 = GUICtrlCreateTabItem("")
    $TabSheet4 = GUICtrlCreateTabItem("")
    $TabSheet5 = GUICtrlCreateTabItem("About")
        GUICtrlSetState(-1,$GUI_SHOW)
    $Label3 = GUICtrlCreateLabel("Made By: Ray Smith", 140, 41, 106, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label2 = GUICtrlCreateLabel("Thanks", 148, 58, 40, 19, $SS_CENTER)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label4 = GUICtrlCreateLabel("Smoke", 160, 76, 38, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label5 = GUICtrlCreateLabel("Prodigy", 160, 92, 43, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label6 = GUICtrlCreateLabel("BB_HIT_MAN", 160, 108, 80, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Label7 = GUICtrlCreateLabel("Version:  1.04", 174, 138, 74, 19)
        GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS")
    $Pic1 = GUICtrlCreatePic("Pic1.gif", 0, 40, 140, 114, 0, $GUI_WS_EX_PARENTDRAG)
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlCreateTabItem("")
        $playk = "^!{ins}"
        $stopk = "^!{end}"
        $pausek = "^!{home}"
        $volupk = "^!{up}"
        $voldnk = "^!{down}"
        $nextk = "^!{left}"
        $previousk = "^!{right}"
        $snoozek = "{space}"
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case - 3
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button21
                GUIDelete(HWnd($Setup))
                Return $OptGOEM
            Case $Button4
                Run($winampdir & "\winamp.exe")
            Case $Button1 
                IniWrite("alarm.ini", "time", "sleep", GUICtrlRead($SnoozeTime) * 1000)
                IniWrite("alarm.ini", "other", "closewinamp", GUICtrlRead($CheckBox1))
                IniWrite("alarm.ini", "other", "closescript", GUICtrlRead($CheckBox2))
                IniWrite("alarm.ini", "hotkeys", "play", $playk)
                IniWrite("alarm.ini", "hotkeys", "stop", $stopk)
                IniWrite("alarm.ini", "hotkeys", "pause", $pausek)
                IniWrite("alarm.ini", "hotkeys", "volup", $volupk)
                IniWrite("alarm.ini", "hotkeys", "voldn", $voldnk)
                IniWrite("alarm.ini", "hotkeys", "next", $nextk)
                IniWrite("alarm.ini", "hotkeys", "previous", $previousk)
                IniWrite("alarm.ini", "hotkeys", "snooze", $snoozek)
        EndSwitch
    WEnd
EndFunc
Func _iniread()
;Other
    $endkey = "{end}"
    $winampdir =  IniRead ("alarm.ini", "other", "winampdir", "")
    $closewinamp = IniRead ("alarm.ini", "other", "closewinamp", "4")
    $closescript = IniRead ("alarm.ini", "other", "closescript", "4")
;Delays
    $sleep = IniRead ("alarm.ini", "time", "sleep", "00")
    
;Keys
    $play = IniRead ("alarm.ini", "hotkeys", "play", "^!{ins}")
    $stop = IniRead ("alarm.ini", "hotkeys", "stop", "^!{end}")
    $pause = IniRead ("alarm.ini", "hotkeys", "pause", "^!{home}")
    $volup = IniRead ("alarm.ini", "hotkeys", "volup", "^!{up}")
    $voldn = IniRead ("alarm.ini", "hotkeys", "voldn", "^!{down}")
    $next = IniRead ("alarm.ini", "hotkeys", "next", "^!{left}")
    $previous = IniRead ("alarm.ini", "hotkeys", "previous", "^!{right}")
    $snoozekey = IniRead ("alarm.ini", "hotkeys", "snooze", "{space}")
    
        HotKeySet($snoozekey, "_Snooze")
        HotKeySet($endkey, "Terminate")
EndFunc
Func _GetHour($iHour)
    Switch $iHour
        Case 12
            $AMPM = 'PM'
            Return $iHour
        Case 13 To 23
            $AMPM = 'PM'
            Return $iHour - 12
        Case 0
            $AMPM = 'AM'
            Return 12
        Case 1 To 11
            $AMPM = 'AM'
            Return $iHour
    EndSwitch
EndFunc
Func _SwitchHour($iHour)
    Switch $iHour
        Case 12
            If $AMPM = 'AM' Then
                Return 0
            Else
                Return 12
            EndIf
        Case 1 To 11
            If $AMPM = 'PM' Then
                Return $iHour + 12
            Else
                Return $iHour
            EndIf
    EndSwitch
EndFunc
Func _Snooze()
    send($pause)
    Sleep($sleep)
    PlayTime()
EndFunc
Func SleepTime();
    Stop()
;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func PlayTime();
    Play()
;If $closewinamp = 1 then 
    If $closescript = 1 Then Terminate()
EndFunc
Func Play()
    Send($play)
EndFunc
Func Stop()
    Send($stop)
EndFunc
Func VolUp()
    Send($volup)
EndFunc
Func VolDown()
    Send($voldn)
EndFunc
Func _Next()
    Send($next)
EndFunc
Func _Previous()
    Send($previous)
EndFunc
Func Terminate()
    Exit
EndFunc
Edited by Golbez

Share this post


Link to post
Share on other sites

I didn't read through all of this (sorry) but if you don't want your user(s) to have to edit the ini file then you can do a check for a value like "runonce" equal to "1" or true or something and if it isnt then do a prompt for a value then write it to the ini file itself and then once it's been run once use a iniwrite(main,runonce,true) or whatever the syntax is ... i hope that made sense...

Share this post


Link to post
Share on other sites

I didn't read through all of this (sorry) but if you don't want your user(s) to have to edit the ini file then you can do a check for a value like "runonce" equal to "1" or true or something and if it isnt then do a prompt for a value then write it to the ini file itself and then once it's been run once use a iniwrite(main,runonce,true) or whatever the syntax is ... i hope that made sense...

lol read my script..

i got that and more my question is i want an input box where when the user selects the input box then PRESSES the keys there hotkeys are it automaticly puts them in there.

ex:

input box. i click on it. press CTRL+ALT+G

the input box will now read ^!{G}

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0