NewBe Posted February 3, 2008 Share Posted February 3, 2008 I have a couple things I can't figure out, I have made a notepad and it turned out good so far except for a few small problems. I want to add music to my notepad this works but the _MusicPlay() function stops the script from doing stuff because of soundplay("myfile" , 1) instead of soundplay("myfile") and I don't know of a way to make it work because it does it in a For Next loop and even if I took that part out how will it know to play the next song? Func _MusicPlay() If Not IsArray($Playlist) Then MsgBox(0, "", "please make a playlist first") EndIf For $Song = 1 To Ubound($Playlist) -1 SoundPlay($Playlist[$Song] , 1) Next EndFunc Func _Previous() SoundPlay("") $i = $i - 1 _MusicPlay() EndFunc Func _Next() SoundPlay("") $i = $i + 1 _MusicPlay() EndFunc Func _MusicList() $AddMusic = FileOpenDialog("Add Music" , "" , "All Media (*.*)") If @Error Then MsgBox(4096, "" , "No File chosen") Else FileWrite(@ScriptDir & "\Play List.txt" , $AddMusic & @CRLF) _LoadPlaylist() EndIf EndFunc Func _LoadPlaylist() _FileReadToArray(@ScriptDir & "\Play List.txt", $Playlist) EndFuncoÝ÷ Úl©jË^~éܶ*'Â䲫}ç-nëg¢Û.èhÂÚ&jGrr~éܶ*'jwHv÷öÜÛh©ÙbëaÆ®¶sd6ÆWBb33cµFWBå6VÅFWB I don't want to GUICtrlCreateObj() if there is another way of copying highlighted text and I also need a function to highlight all text. If I can find ways to do all theses I will be set to move on to the fun functions. again I am sorry if you can't understand me my english is poor I can only type english from taking it a bit in school and using google Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2008 Share Posted February 3, 2008 I want to add music to my notepad this works but the _MusicPlay() function stops the script from doing stuff because of soundplay("myfile" , 1) instead of soundplay("myfile") and I don't know of a way to make it work because it does it in a For Next loop and even if I took that part out how will it know to play the next song?Just use an AdLibEnable() function to periodically check on the music (like every 500ms). When _SoundPos = _SoundLength, then it's time to move on to the next song. 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...
NewBe Posted February 3, 2008 Author Share Posted February 3, 2008 Just use an AdLibEnable() function to periodically check on the music (like every 500ms). When _SoundPos = _SoundLength, then it's time to move on to the next song. but thats mean I would have to use _SoundPlay() instead of SoundPlay() and I never used AdLibEnable() can you maybe post an example? Link to comment Share on other sites More sharing options...
NewBe Posted February 3, 2008 Author Share Posted February 3, 2008 can't move on in my project since I don't understand a proper way to do things Link to comment Share on other sites More sharing options...
BrettF Posted February 3, 2008 Share Posted February 3, 2008 The helpfile is wonderful :rollseyes: Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2008 Share Posted February 3, 2008 but thats mean I would have to use _SoundPlay() instead of SoundPlay() and I never used AdLibEnable() can you maybe post an example?...soooo you use functions that do what you want to do, learning new things and increasing your skilz in the process.I'm sorry, what was the downside? Any way, it's a good example to learn a few things from, so here are few starters:To get the more advanced features and use them, you have to use a slightly more complicated way to handle the sound.You already intend to have the songs in an array, so you call AdLibEnable() and name the function you want run periodically.Inside that function, you check if a song is already playing, and if not you _SoundOpen()/_SoundPlay() the next song, saving the "alias" to a Global variable. If there is a song playing already, you check if it has played to the end by comparing _SoundPos() with _SoundLength(). If it's at the end of the song, then _SoundClose() the current song and _SoundOpen()/_SoundPlay() the next.Read up on those functions in the help file and take a shot at it. If it doesn't work, post your code for more help. In the end you'll have both the script you want and new tools you know how to use. 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...
NewBe Posted February 3, 2008 Author Share Posted February 3, 2008 expandcollapse popup#include <File.au3> #include <Sound.au3> #include <GUIConstants.au3> Global $i , $Playlist $Form1 = GUICreate("Form1", 200, 200) $Play = GUICtrlCreateButton("Play", 0, 0, 75, 25, 0) $Stop = GUICtrlCreateButton("Stop", 0, 0, 75, 25, 0) $Prev = GUICtrlCreateButton("Prev", 0, 25, 75, 25, 0) $Next = GUICtrlCreateButton("Next", 0, 50, 75, 25, 0) $Load = GUICtrlCreateButton("Load", 0, 75, 75, 25, 0) GUISetState(@SW_SHOW) $i = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Play _MusicPlay() Case $Stop _SoundClose($Playlist) Case $Prev _Previous() Case $Next _Next() Case $Load _MusicList() EndSwitch WEnd Func _MusicPlay() If Not IsArray($Playlist) Then MsgBox(0, "", "please make a playlist first") EndIf For $Song = 1 To UBound($Playlist) -1 _SoundPlay($Playlist[$Song]) Next EndFunc Func _Previous() _SoundClose($Playlist) $i = $i - 1 _MusicPlay() EndFunc Func _Next() _SoundClose($Playlist) $i = $i + 1 _MusicPlay() EndFunc Func _MusicList() $AddMusic = FileOpenDialog("Add Music" , "" , "All Media (*.*)") If @Error Then MsgBox(4096, "" , "No File chosen") Else FileWrite(@ScriptDir & "\Play List.txt" , $AddMusic & @CRLF) _LoadPlaylist() EndIf EndFunc Func _LoadPlaylist() _FileReadToArray(@ScriptDir & "\Play List.txt", $Playlist) EndFunc for some reason I don't even have to call the function and it opens all the songs I tried it is hard reading autoit help file I have to keep translating it that is the whole purpose of me making my notepad maybe I should of worked on that first though lol but anyways this music part is almost done just need to fix that. Link to comment Share on other sites More sharing options...
JustinReno Posted February 3, 2008 Share Posted February 3, 2008 (edited) Ok, I was intrigued by your idea, and made a simple looking media player that should have all you need. Its 110 lines of code and took me over an hour to make it.Here is a screenshot, and I'll give you the source if you want: Edited February 3, 2008 by JustinReno Link to comment Share on other sites More sharing options...
BrettF Posted February 3, 2008 Share Posted February 3, 2008 Ok, I was intrigued by your idea, and made a simple looking media player that should have all you need. Its 110 lines of code and took me over an hour to make it.Here is a screenshot, and I'll give you the source if you want:Wow. Those buttons suck. Make them spaced by around 3px from every other control and the edge of the GUI. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
JustinReno Posted February 3, 2008 Share Posted February 3, 2008 (edited) I know, I mean't to fix them later, but I forgot, I'll fix it. And I had to select the area were the GUI was, so the edge is cut off. Ok, I got them fixed, Let me fix the other post... Edited February 3, 2008 by JustinReno Link to comment Share on other sites More sharing options...
NewBe Posted February 3, 2008 Author Share Posted February 3, 2008 If you could give me the source that would be a great help. Thanks Link to comment Share on other sites More sharing options...
JustinReno Posted February 4, 2008 Share Posted February 4, 2008 Features: 1. Play/Pause/Resume/Stop 2. Load Sound, Load Sounds 3. I plays next sound after the previous was done. 4. It saves music as a playlist. 5. Fast/Simple 6. Shows Position of the sound and length. expandcollapse popup#NoTrayIcon #Include <GUIConstants.au3> #Include <Sound.au3> #Include <File.au3> #Include <GUIListBox.au3> Global $Ini = @ScriptDir & "\Music Playlist.ini" Global $Sound $GUI = GUICreate("Newbie's New Music Player", 255, 165, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) $SoundList = GUICtrlCreateList("", 0, 16, 105, 149) GUICtrlCreateLabel("Play List:", 0, 0, 46, 17) $LoadSound = GUICtrlCreateButton("Load Sound", 104, 16, 75, 17, 0) $LoadSounds = GUICtrlCreateButton("Load Sounds", 181, 16, 75, 17, 0) $DeleteSound = GUICtrlCreateButton("Delete Sound", 104, 35, 152, 17, 0) $PlaySound = GUICtrlCreateButton("Play Sound", 104, 56, 75, 17, 0) $PauseSound = GUICtrlCreateButton("Pause Sound", 181, 56, 75, 17, 0) $ResumeSound = GUICtrlCreateButton("Resume Sound", 104, 75, 75, 17, 0) $StopSound = GUICtrlCreateButton("Stop Sound", 181, 75, 75, 17, 0) $SoundPosition = GUICtrlCreateLabel("00:00:00/00:00:00", 136, 96, 93, 17) GUISetState(@SW_SHOW) If FileExists($Ini) Then _PopulateSoundList() While 1 If FileExists($Ini) And $Sound <> "" Then _NextSound() If $Sound <> "" Then GUICtrlSetData($SoundPosition, _SoundPos($Sound) & "/" & _SoundLength($Sound)) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $SoundList If FileExists($Ini) Then $GetSoundName = GUICtrlRead($SoundList) $GetSoundsFromIni = IniReadSection($Ini, "Sounds") For $A = 1 To $GetSoundsFromIni[0][0] If $GetSoundName = $GetSoundsFromIni[$A][0] Then _SoundClose($Sound) $Sound = _SoundOpen($GetSoundsFromIni[$A][1], $GetSoundName) _SoundPlay($Sound, 0) EndIf Next EndIf Case $LoadSound $GetSound = FileOpenDialog("Newbie's New Music Player - Add Sound", @ScriptDir, "Music(*.mp3;*.wav)") If Not @error Then $GetSoundName = StringSplit($GetSound, "\") IniWrite($Ini, "Sounds", $GetSoundName[$GetSoundName[0]], $GetSound) GUICtrlSetData($SoundList, $GetSoundName[$GetSoundName[0]]) EndIf Case $LoadSounds $GetSounds = FileSelectFolder("Newbie's New Music Player - Add Sounds", @HomeDrive) If Not @error Then $GetFiles = _FileListToArray($GetSounds, "*.mp3") For $B = 1 To $GetFiles[0] IniWrite($Ini, "Sounds", $GetFiles[$B], $GetSounds & "\" & $GetFiles[$B]) GUICtrlSetData($SoundList, $GetFiles[$B]) Next EndIf Case $DeleteSound If FileExists($Ini) Then $GetSound = GUICtrlRead($SoundList) If $GetSound = $Sound Then _SoundClose($Sound) IniDelete($Ini, "Sounds", $GetSound) _GUICtrlListBox_DeleteString ($SoundList, _GUICtrlListBox_GetCurSel ($SoundList)) _PopulateSoundList() EndIf Case $PlaySound If FileExists($Ini) Then $GetSound = GUICtrlRead($SoundList) $GetSounds = IniReadSection($Ini, "Sounds") For $C = 1 To $GetSounds[0][0] If $GetSound = $GetSounds[$C][0] Then _SoundClose($Sound) $Sound = _SoundOpen($GetSounds[$C][1]) _SoundPlay($Sound, 0) EndIf Next EndIf Case $PauseSound If $Sound <> "" Then _SoundPause($Sound) Case $ResumeSound If $Sound <> "" Then _SoundResume($Sound) Case $StopSound If $Sound <> "" Then _SoundStop($Sound) _SoundClose($Sound) $Sound = "" EndIf EndSwitch WEnd Func _NextSound() If _SoundPos($Sound, 2) = _SoundLength($Sound, 2) Then _SoundClose($Sound) _GUICtrlListBox_SetCurSel ($SoundList, _GUICtrlListBox_GetCurSel ($SoundList) + 1) $GetNewSoundName = GUICtrlRead($SoundList) $GetSoundNames = IniReadSection($Ini, "Sounds") For $D = 1 To $GetSoundNames[0][0] If $GetNewSoundName = $GetSoundNames[$D][0] Then _SoundClose($Sound) $Sound = _SoundOpen($GetSoundNames[$D][1]) _SoundPlay($Sound, 0) EndIf Next EndIf EndFunc ;==>_NextSound Func _PopulateSoundList() $GetSounds = IniReadSection($Ini, "Sounds") If @error Then FileDelete($Ini) If FileExists($Ini) Then For $E = 1 To $GetSounds[0][0] GUICtrlSetData($SoundList, $GetSounds[$E][0]) Next EndIf EndFunc ;==>_PopulateSoundList Link to comment Share on other sites More sharing options...
NewBe Posted February 4, 2008 Author Share Posted February 4, 2008 Thanks ill give it a try tomorrow. I think all I need now is to find a way to copy and select all text with out using rich text edit thing I hope it is possible without it I am not sure if everyone has this but when I click on my edit control (text box) it gives me an option to copy , paste , select all can I some how use thoses with controlsend() or something. Link to comment Share on other sites More sharing options...
JustinReno Posted February 4, 2008 Share Posted February 4, 2008 For Copy: ClipPut(GuiCtrlRead($Edit)oÝ÷ ØZ+Ié^rÐ%«¢+Ù±± ±° ÅÕ½ÐíUÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí±ÁÉ´ÅÕ½Ðì°ÅÕ½ÐíM¹5ÍÍÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì° ½¹Ñɽ±Ñ!¹± ÀÌØíU$°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥Ð¤°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÁáÄ°ÅÕ½ÐíÝÁÉ´ÅÕ½Ðì°À°ÅÕ½Ðí±ÁÉ´ÅÕ½Ðì°MÑÉ¥¹1¸¡U% ÑɱI ÀÌØí¥Ð¤¤¤ Link to comment Share on other sites More sharing options...
BrettF Posted February 4, 2008 Share Posted February 4, 2008 For Copy: ClipPut(GuiCtrlRead($Edit)oÝ÷ ØZ+Ié^rÐ%«¢+Ù±± ±° ÅÕ½ÐíUÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí±ÁÉ´ÅÕ½Ðì°ÅÕ½ÐíM¹5ÍÍÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì° ½¹Ñɽ±Ñ!¹± ÀÌØíU$°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥Ð¤°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÁáÄ°ÅÕ½ÐíÝÁÉ´ÅÕ½Ðì°À°ÅÕ½Ðí±ÁÉ´ÅÕ½Ðì°MÑÉ¥¹1¸¡U% ÑɱI ÀÌØí¥Ð¤¤¤Forgot a bracket... Nice job JR. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
NewBe Posted February 4, 2008 Author Share Posted February 4, 2008 For Copy:autoit tags are problems.Thanks for the select all worked perfect but I already had that copy function it selects all text. 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