mrbond007 Posted January 30, 2007 Share Posted January 30, 2007 since i don't know how to monitor the sound output , i created this small script to put those lock buttons to good use. so i need your opinion (go easy on me plz). CODE #include <GUIConstants.au3> #include <Sound.au3> Opt("GUIOnEventMode", 1) Opt("TrayIconHide", 1) $message = "Choose zee song" $LAB1 = HotKeySet("{F2}", "Choose") $LAB2 = HotKeySet("{F3}", "Play") $LAB3 = HotKeySet("{F4}", "Stop") $LAB4 = HotKeySet("{ESC}", "Kill") $lee = GUICreate("QuiK Pleya", 200, 125, 190, 100) GUICtrlCreateLabel("****Press Esc to Quit****", 40, 10) GUICtrlSetColor(-1, 0x006CD9) GUICtrlCreateLabel("****Press F2 to Choose****", 40, 40) GUICtrlSetColor(-1, 0x006CD9) GUICtrlCreateLabel("****Press F3 to Play****", 40, 70) GUICtrlSetColor(-1, 0x006CD9) GUICtrlCreateLabel("****Press F4 to Stop****", 40, 100) GUICtrlSetColor(-1, 0x006CD9) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($LAB2, "Play") GUICtrlSetOnEvent($LAB3, "Stop") GUICtrlSetOnEvent($LAB4, "Kill") GUISetOnEvent($GUI_EVENT_CLOSE, "Kill") $file = FileOpenDialog($message, "", "Songs (*.mp3;*.mid;*.wav)", 1) If @error Then MsgBox(4096,"","No File is chosen") Exit EndIf $op = _SoundOpen ($file) $pl = _SoundPlay ($op) _SoundStop ($op) While 1 Sleep(50) WEnd Func Choose() $pl = False _SoundStop ($op) _SoundClose ($op) $file = FileOpenDialog($message, "", "Songs (*.mp3;*.mid;*.wav)", 1) If @error Then MsgBox(4096,"","No File is chosen") Exit EndIf $op = _SoundOpen ($file) EndFunc Func Play() _SoundPlay ($op) $pl = True Sleep(200) ; REmMOVE iF YOU HAVE A FAST MACHiNE While $pl = True $alfa = Random(0, 2, 1) If $alfa = 0 Then Send("{NUMLOCK toggle}") Sleep(25) If $alfa = 1 Then Send("{CAPSLOCK toggle}") Sleep(25) If $alfa = 2 Then Send("{SCROLLLOCK toggle}") Sleep(25) If _SoundPos($op, 2) = _SoundLength($op, 2) Then ExitLoop WEnd EndFunc Func Stop() $pl = False _SoundStop ($op) EndFunc Func Kill() _SoundClose ($op) Send("{NUMLOCK off}") Send("{CAPSLOCK off}") Send("{SCROLLLOCK off}") Exit EndFunc Side effects are it's better not to use keys combs like ALT+TAB while using this script, and on older windows versions the lock buttons may act weird. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight Link to comment Share on other sites More sharing options...
mrbond007 Posted January 30, 2007 Author Share Posted January 30, 2007 i forgot to say that the sleep(25) inside the loop works fine with most songs, but you can choose a value of 10 for fast songs. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight Link to comment Share on other sites More sharing options...
Uten Posted January 30, 2007 Share Posted January 30, 2007 I have to admit it took me a while to understand what you were after. You want the led's in your keyboard to act as disco lights .. You could atleast optimize this part: While $pl = True $alfa = Random(0, 2, 1) If $alfa = 0 Then Send("{NUMLOCK toggle}") Sleep(25) If $alfa = 1 Then Send("{CAPSLOCK toggle}") Sleep(25) If $alfa = 2 Then Send("{SCROLLLOCK toggle}") Sleep(25) If _SoundPos($op, 2) = _SoundLength($op, 2) Then ExitLoop WEndoÝ÷ Ù:ºÚ"µÍÚ[H ÌÍÜHYBÌÍØ[HH[ÛJJBÓÕNÛH][X]HÛÙKÛÝ[H[ÝH]HÈXZÈ]ÈÙ]H[È[[ÚÚ]H[YY ÌÍØ[HH[Ù[ ][ÝÞÓSSÐÒÈÙÙÛ_I][ÝÊB[ÙRY ÌÍØ[HHH[Ù[ ][ÝÞÐÐTÓÐÒÈÙÙÛ_I][ÝÊB[ÙRY ÌÍØ[HH[Ù[ ][ÝÞÔÐÔÓÐÒÈÙÙÛ_I][ÝÊBYÔÛÝ[ÜÊ ÌÍÛÜHHÔÛÝ[[Ý ÌÍÛÜH[^]ÛÜÛY [ÛJK ÍKJHÑ[ Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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