tskedition Posted September 18, 2011 Share Posted September 18, 2011 How to stop previous sound playing when new sound opens hotkeyset("{PAUSE}", "endscript") $done=0 do if(PixelGetColor(1179, 132)==6184542) Then SoundPlay("C:\arse\rpm idle11.wav" ,1) if(PixelGetColor(1179, 132)==8289918) Then SoundPlay("C:\arse\rpm high 1.wav" ,1) sleep(10) until $done=1 Func endscript() tooltip("") $done=1 exit EndFunc ;end endscript() Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 18, 2011 Share Posted September 18, 2011 See the Remarks - Function SoundPlay - 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...
tskedition Posted September 18, 2011 Author Share Posted September 18, 2011 i dont get it what is wrong with my script then Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 18, 2011 Share Posted September 18, 2011 Change if(PixelGetColor(1179, 132)==6184542) Then SoundPlay("C:\arse\rpm idle11.wav" ,1) if(PixelGetColor(1179, 132)==8289918) Then SoundPlay("C:\arse\rpm high 1.wav" ,1) to if(PixelGetColor(1179, 132)==6184542) Then SoundPlay("") SoundPlay("C:\arse\rpm idle11.wav" ,1) EndIf if(PixelGetColor(1179, 132)==8289918) Then SoundPlay("") SoundPlay("C:\arse\rpm high 1.wav" ,1) EndIf See if that works more the way you want. Also, the 1 flag will play the sound file all the way thru before the script continues running, you know. - 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...
Moderators Melba23 Posted September 18, 2011 Moderators Share Posted September 18, 2011 tskedition, Which part of:Calling SoundPlay("") can be used to stop a currently playing soundis difficult to understand? Just do that before playing a new sound: If PixelGetColor(1179, 132) = 6184542 Then SoundPlay("") SoundPlay("C:\arse\rpm idle11.wav" ,1) EndIfNote that == is only required when making case-sensitive string comparisons. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 18, 2011 Share Posted September 18, 2011 Oops, I didn't catch the unnecessary use of ==. Thanks M23. - 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...
Moderators Melba23 Posted September 18, 2011 Moderators Share Posted September 18, 2011 somdcomputerguy, Using it can slow the script significantly if you do so unnecessarily in a loop, so it is best to keep it to its intended function. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tskedition Posted September 18, 2011 Author Share Posted September 18, 2011 if i change idle11.wav" ,1) to idle11.wav" ,0) it plays lots of sounds on top of each other .How to make script play loop when pixel color is 6184542 and stop previous sound half way when pixel color changes to 8289918 and play other sound loop .Sound files are about 5 seconds long . sorry my scripting skill is bad and i dont have time to learn all this Link to comment Share on other sites More sharing options...
tskedition Posted September 18, 2011 Author Share Posted September 18, 2011 i would not need to play different sounds if i could just make 1 audio file to change its playng speed then different pixel colors would set speed of the sound sort of fast forward. I am just trying to make engine sound to a program that does not have any sound. Program is called Algodoo its 2d phisics simulator and this script would make many people happy. Link to comment Share on other sites More sharing options...
tskedition Posted September 18, 2011 Author Share Posted September 18, 2011 pixel stays at color 6184542 until it changes to 8289918 and other way around .There will be more than two colors if i get it to work Link to comment Share on other sites More sharing options...
JohnOne Posted September 18, 2011 Share Posted September 18, 2011 What is wrong with the examples you have been given? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tskedition Posted September 18, 2011 Author Share Posted September 18, 2011 Sorry but example didn't change the way script worked for me.My problem is that when pixel color changes first sounds plays to the end and then starts second sound but it needs to start immediately.And when i change 1 to 0 (0= continue script while sound is playing) and pixel does not change,then script plays bits of sounds on top of each other and makes my pc run slow. What am i doing wrong? I should add that this script is for Algodoo software and i need sound for engine on different rpm.Algodoo has also scripting possibility and i think i can make some part of screen change color from lighter to darker according to engine rpm.Maybe there is another way accomplishing that engine sound its not important what script i use just final effect is important. Link to comment Share on other sites More sharing options...
JohnOne Posted September 18, 2011 Share Posted September 18, 2011 Show your current script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tskedition Posted September 19, 2011 Author Share Posted September 19, 2011 hotkeyset("{PAUSE}", "endscript") $done=0 do if(PixelGetColor(1179, 132)=6184542) Then SoundPlay("") SoundPlay("C:\arse\rpm idle11.wav",2) EndIf if(PixelGetColor(1179, 132)=8289918) Then SoundPlay("") SoundPlay("C:\arse\rpm high 1.wav",2) EndIf sleep(10) until $done=1 Func endscript() tooltip("") $done=1 exit EndFunc ;end endscript() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2011 Moderators Share Posted September 19, 2011 tskedition,My apologies, I did not notice before that you had the "wait" parameter set for your SoundPlay commands. You need to allow the script to continue while the sound is playing, so this parameter must NOT be set. Try this - it works for me when I test it: HotKeySet("{PAUSE}", "endscript") $done = 0 Do If (PixelGetColor(1179, 132) = 6184542) Then SoundPlay("") SoundPlay("C:\arse\rpm idle11.wav") EndIf If (PixelGetColor(1179, 132) = 8289918) Then SoundPlay("") SoundPlay("C:\arse\rpm high 1.wav") EndIf Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFuncNow the script will continue and the SoundPlay("") will stop the current sound before playing the new one. Has that solved the problem for you? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2011 Share Posted September 19, 2011 (edited) What do you expect to happen with a flag of 2 in that function? EDIT: probably just acts as 1, being positive. Edited September 19, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tskedition Posted September 19, 2011 Author Share Posted September 19, 2011 I did change script added more audio files and colors.But still does not work like i want to.Maybe its just my computers fault.So I uploaded video to youtube to explain what final result should look like and to show my problems with script. http://www.youtube.com/watch?v=3YXjrFxCXLw expandcollapse popupHotKeySet("{PAUSE}", "endscript") $done = 0 Do If (PixelGetColor(1179, 132) = 0x333333) Then SoundPlay("") SoundPlay("C:\arse\rpm 100.wav") EndIf If (PixelGetColor(1179, 132) = 0x4C4C4C) Then SoundPlay("") SoundPlay("C:\arse\rpm 150.wav") EndIf If (PixelGetColor(1179, 132) = 0x666666) Then SoundPlay("") SoundPlay("C:\arse\rpm 200.wav") EndIf If (PixelGetColor(1179, 132) = 0x808080) Then SoundPlay("") SoundPlay("C:\arse\rpm 250.wav") EndIf If (PixelGetColor(1179, 132) = 0x999999) Then SoundPlay("") SoundPlay("C:\arse\rpm 300.wav") EndIf If (PixelGetColor(1179, 132) = 0xB2B2B2) Then SoundPlay("") SoundPlay("C:\arse\rpm 350.wav") EndIf If (PixelGetColor(1179, 132) = 0xCCCCCC) Then SoundPlay("") SoundPlay("C:\arse\rpm 400.wav") EndIf Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2011 Moderators Share Posted September 19, 2011 (edited) tskedition, A light dawns! We need to check if the colour has changed or you will keep playing the same sound over and over again. Perhaps this will work:expandcollapse popupHotKeySet("{PAUSE}", "endscript") $done = 0 $iCurr_Colour = 0 ; This is to store the colour at the moment Do $iColour = PixelGetColor(1179, 132) ; Get the current colour Switch $iColour Case 0x333333 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not restart the sound SoundPlay("") SoundPlay("C:\arse\rpm 100.wav") ; Play the new sound only when the colour changes EndIf Case 0x4C4C4C If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 150.wav") EndIf Case 0x666666 If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 200.wav") EndIf Case 0x808080 If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 250.wav") EndIf Case 0x999999 If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 300.wav") EndIf Case 0xB2B2B2 If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 350.wav") EndIf Case 0xCCCCCC If $iCurr_Colour <> $iColour Then $iCurr_Colour = $iColour SoundPlay("") SoundPlay("C:\arse\rpm 400.wav") EndIf EndSwitch Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFuncMy only concern is that you may need to run the sound for longer than the wav file lasts. if so then we might need to look at using the Sound.au3 UDF which can restart the sound if needed. M23 Edit: Why does this updowngraded editor remove \ from any paths. Edited September 19, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2011 Share Posted September 19, 2011 (edited) I would add a flag to tell autoit not to stop and restart the sound if the rpm has not changed. Something like this... expandcollapse popupHotKeySet("{PAUSE}", "endscript") $done = 0 $RPM = 0 Do If (PixelGetColor(1179, 132) = 0x333333) And $RPM <> 100 Then $RPM = 100 SoundPlay("") SoundPlay("C:\arse\rpm 100.wav") EndIf If (PixelGetColor(1179, 132) = 0x4C4C4C) And $RPM <> 150 Then $RPM = 150 SoundPlay("") SoundPlay("C:\arse\rpm 150.wav") EndIf If (PixelGetColor(1179, 132) = 0x666666) And $RPM <> 200 Then $RPM = 200 SoundPlay("") SoundPlay("C:\arse\rpm 200.wav") EndIf If (PixelGetColor(1179, 132) = 0x808080) And $RPM <> 250 Then $RPM = 250 SoundPlay("") SoundPlay("C:\arse\rpm 250.wav") EndIf If (PixelGetColor(1179, 132) = 0x999999) And $RPM <> 300 Then $RPM = 300 SoundPlay("") SoundPlay("C:\arse\rpm 300.wav") EndIf If (PixelGetColor(1179, 132) = 0xB2B2B2) And $RPM <> 350 Then $RPM = 350 SoundPlay("") SoundPlay("C:\arse\rpm 350.wav") EndIf If (PixelGetColor(1179, 132) = 0xCCCCCC) And $RPM <> 400 Then $RPM = 400 SoundPlay("") SoundPlay("C:\arse\rpm 400.wav") EndIf Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFunc ;==>endscript EDIT: pipped to the post. Edited September 19, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2011 Moderators Share Posted September 19, 2011 JohnOne, Great minds, eh? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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