Jump to content

Staying open


flynch
 Share

Recommended Posts

#include <GUIConstants.au3>

GUICreate("Hello World", 200, 100)

GUICtrlCreateLabel("Music", 60, 8)

GUISetState(@SW_SHOW)

SoundPlay("D:\Music\Song.mp3",0)

Sleep(100000)

This is my first script. Been reading the tuts so you'll recognise it. How do I keep the script open during the song? Without having some obsurd Sleep?

Link to comment
Share on other sites

[optional] This flag determines if the script should wait for the sound to finish before continuing:

1 = wait until sound has finished

0 = continue script while sound is playing (default)

If 1 is there, nothing else in the script will happen because its paused.

If 0 is there, I have to put in a crazy sleep time to stop it quitting 10 seconds into the song.

Link to comment
Share on other sites

You want to play a song in the background? and then have the script exit after its done playing?

Well the one I posted does that. And you can quit by right-clicking the tray icon.... So I don't know.. :)

Link to comment
Share on other sites

When I use the one with (the fish avatar forgot his name) it works fine. But doesn't the sleep thing screw up any other code I want to work? Such as after i play the song, I want to click buttons in the program. Won't it stop me from doing ti until the sleep is finished?

Basic outline:

Open program:

Music plays:

Do stuff in program:

Close whenever you want:

Link to comment
Share on other sites

When I use the one with (the fish avatar forgot his name) it works fine. But doesn't the sleep thing screw up any other code I want to work? Such as after i play the song, I want to click buttons in the program. Won't it stop me from doing ti until the sleep is finished?

Use this then.. should do what you want.

#include <Sound.au3>
$Sound = "path to sound"
$Length = _SoundLength($Sound, 2)
_SoundPlay($Sound, 0)
$timer = TimerInit
While 1
    Sleep(10)
    If TimerDiff($timer) > $Length Then ExitLoop
        ;Do all your stuff here
WEnd
-edit-

wait.. if you want to do something else after, not while playing the song... then there's no problem using sleep() :)

Edited by Nahuel
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...