Sign in to follow this  
Followers 0
xsnow

Program won't run right. Something with sleep.

12 posts in this topic

#1 ·  Posted (edited)

Ok... here it is.

$time = InputBox("Shoutdown time", "Enter time in minutes: ")

If @error = 1 Then Exit

Sleep($time*60*1000)

$WinAmpTitle = WinGetTitle("classname=Winamp v1.x")

WinClose(""& $WinAmpTitle, "")

If I put in 1, 2, 5, minutes it works fine and closes winamp, but when I put in like 15 or 20, it won't close winamp. My screen saver also activates after this long, it's like the won't send the commands through a screen saver. Would that be my problem or is there a limit on sleep? I put the sleep into a while loop to sleep a minute, then loop until time and it still did the same so i'm guessing it's something with my screen saver?

Edit: I just had it run for 20 minutes while on my comptuer and it still didn't close winamp.

It closes winamp after just a few minutes if I select that, but not after this long.

Any ideas?

Edited by xsnow

Share this post


Link to post
Share on other sites



Maximum sleep time is 2147483647 milliseconds (24 days).

So My guess would be, the the screen saver.

Take a look at WinActivate, then try to Activate the window, and send what you want to. Just a shot in the dark.


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

I just set the same to try it, and it would work if I set it for running for liek 2-3 minutes, but for 15-20, it won't close winamp.

Anyone wanna copy my code and try it? It should work for most all versions of winamp.

Share this post


Link to post
Share on other sites

$time = InputBox("Shoutdown time", "Enter time in minutes: ")
If @error = 1 Then Exit

Sleep($time*60*1000)

$WinAmpTitle = WinGetTitle("classname=Winamp v1.x")

WinKill("" & $WinAmpTitle, "")

If I had winamp I'd try this. Give this a shot. Whats with the "" & $WinAmpTitle


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

I just set the same to try it, and it would work if I set it for running for liek 2-3 minutes, but for 15-20, it won't close winamp.

Anyone wanna copy my code and try it? It should work for most all versions of winamp.

Well you tried that quickly seen as that this thread was started like 25 minutes ago :)

I just tried for 4 and 6 minutes, but that both worked. Now I just set it to 20 minutes, will report results back here if nothing was found in the meantime.

Btw, to work around this just use something like this, it will check every 100 ms if enough time has passed then exits.

$timerstart = TimerInit()
$min2wait = 20

While 1
    $mspassed = TimerDiff($timerstart)
    If $mspassed > $min2wait * 60 * 1000 Then ExitLoop
    Sleep(100)
WEnd

WinClose( your program )

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

$time = InputBox("Shoutdown time", "Enter time in minutes: ")
If @error = 1 Then Exit

Sleep($time*60*1000)

$WinAmpTitle = WinGetTitle("classname=Winamp v1.x")

WinKill("" & $WinAmpTitle, "")

If I had winamp I'd try this. Give this a shot. Whats with the "" & $WinAmpTitle

It pulls the title of winamp and closes winamp with that title.

Share this post


Link to post
Share on other sites

It pulls the title of winamp and closes winamp with that title.

What I ment rather, why the "" & ?


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

I totally did not expect it, but you are right! I let my script run for 3 and 6 minutes and it worked (closed notepad). Exactly the same code and notepad document (untitled) were not closed while the script actually did already terminate.

So strange... I am totally clueless here.

$time = InputBox("Shoutdown time", "Enter time in minutes: ")
If @error = 1 Then Exit
Sleep($time*60 *1000)
$WinAmpTitle = WinGetTitle("Naamloos")
WinClose(""& $WinAmpTitle, "")

(It is not actually winamp i used but just a untitled - Notepad ("Naamloos - Kladblok" in Dutch).)


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#10 ·  Posted

I totally did not expect it, but you are right! I let my script run for 3 and 6 minutes and it worked (closed notepad). Exactly the same code and notepad document (untitled) were not closed while the script actually did already terminate.

So strange... I am totally clueless here.

$time = InputBox("Shoutdown time", "Enter time in minutes: ")
If @error = 1 Then Exit
Sleep($time*60 *1000)
$WinAmpTitle = WinGetTitle("Naamloos")
WinClose(""& $WinAmpTitle, "")

(It is not actually winamp i used but just a untitled - Notepad ("Naamloos - Kladblok" in Dutch).)

i'm glad to hear that it's not just me.

Now to figure out Why.

Share this post


Link to post
Share on other sites

#11 ·  Posted

Anyone have any ideas why it won't work the way it is?

Share this post


Link to post
Share on other sites

#12 ·  Posted

Try using the winamp automation library by big daddy:

http://www.autoitscript.com/forum/index.ph...5&hl=winamp

-The Kandie Man ;-)


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
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
Sign in to follow this  
Followers 0