2 SetTimer -1 at same time, and SoundPlay, , 1

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mobadihp
Posts: 6
Joined: 14 Aug 2019, 06:12

2 SetTimer -1 at same time, and SoundPlay, , 1

16 Oct 2019, 05:46

Anyone can help me to make music loop? I was trying like this, but SoundPlay, , 1 make the twinkle label waiting too for it's done

Code: Select all

#SingleInstance, force
#Persistent

Menu, Tray, NoStandard
Menu, Tray, NoIcon
Gui, Font, tBold s120
Gui, Add, Text, +Center vMusic, PLAYING
Gui, Show, , Loop

SetTimer, TwinkleText, -1
SetTimer, MusicLoop, -1
Return

MusicLoop:
SoundPlay, DOFAKIN.mp3, 1
SetTimer, MusicLoop, -1
Return

TwinkleText:
Gui, Font, cRed
GuiControl, Font, Music
Sleep, 1000
Gui, Font, cBlack
GuiControl, Font, Music
Sleep, 1000
SetTimer, TwinkleText, -1
Return
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: 2 SetTimer -1 at same time, and SoundPlay, , 1

16 Oct 2019, 20:17

Soundplay is a very simple command and certainly not ideally suited for things like this, but one possible and easy workaround might be to create a timer that calls Soundplay after a certain time, that means, the time that the sound file needs to run once...

Code: Select all

;[...]
SetTimer, TwinkleText, -1
gosub, MusicLoop 
SetTimer, MusicLoop, 10500
Return

MusicLoop:
SoundPlay, DOFAKIN.mp3
Return
; [...]
This code assumes that your mp3 takes 10.5 seconds (10500 milliseconds) to run once - but this won't be necessarily an exact procedure...

For more precise looping, given this setting with the constantly flashing GUI, external software/DLLs might help... or perhaps AHK_H ?!
Putting the soundplay part in a separate script that is controlled by the main script, might be another option.
mobadihp
Posts: 6
Joined: 14 Aug 2019, 06:12

Re: 2 SetTimer -1 at same time, and SoundPlay, , 1

17 Oct 2019, 07:15

gregster wrote:
16 Oct 2019, 20:17
Soundplay is a very simple command and certainly not ideally suited for things like this, but one possible and easy workaround might be to create a timer that calls Soundplay after a certain time, that means, the time that the sound file needs to run once...

Code: Select all

;[...]
SetTimer, TwinkleText, -1
gosub, MusicLoop 
SetTimer, MusicLoop, 10500
Return

MusicLoop:
SoundPlay, DOFAKIN.mp3
Return
; [...]
This code assumes that your mp3 takes 10.5 seconds (10500 milliseconds) to run once - but this won't be necessarily an exact procedure...

For more precise looping, given this setting with the constantly flashing GUI, external software/DLLs might help... or perhaps AHK_H ?!
Putting the soundplay part in a separate script that is controlled by the main script, might be another option.
Thanks for your help, i'll try another option then.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: 2 SetTimer -1 at same time, and SoundPlay, , 1

17 Oct 2019, 11:10

I haven't had to deal with Soundplay many times in the past.

When I had used it, I just put the soundplay in another script and used the first script to run it whenever I wanted it to play/ play again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid, Chunjee, icyolive, inseption86, joedf, Swiftly9767 and 302 guests