Senrathy Posted March 10, 2008 Share Posted March 10, 2008 (edited) Hello ;D I´m new on AutoIt and I want to know how can I make my script close a window (like media player) in an estipulated hour (like 3 AM, 12 AM)??? Edited March 10, 2008 by Senrathy Link to comment Share on other sites More sharing options...
prasingh Posted March 10, 2008 Share Posted March 10, 2008 WinWaitClose ( "title" [, "text" [, timeout]] ) I think it should work for you. A smile costs nothing!!!! :-) Link to comment Share on other sites More sharing options...
Monamo Posted March 10, 2008 Share Posted March 10, 2008 Hello ;DI´m new on AutoIt and I want to know how can I make my script close a window (like media player) in an estipulated hour (like 3 AM, 12 AM)???Here's a generic way of handling it:CODE$closeHour = "03"$closeMin = "00"$timeClose = $closeHour &$closeMinDo Sleep(1000) $time = @HOUR &@MINUntil $time = $timeCloseProcessClose("wmplayer.exe") - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
d4rk Posted March 10, 2008 Share Posted March 10, 2008 WinWaitClose ( "title" [, "text" [, timeout]] ) I think it should work for you.sorry but i think you misunderstand the WinWaitClose func, as describe, it's Pauses execution of the script until the requested window does not exist. So it won't help make a window close in a targeted time i haven't checked but i think it shoul be like this : $hrs = @hour if $hrs=3 then;change as you want winclose("Window Media Player",""); please check the exact title, i write this from my memory and i have a bad ones :rolleyes: msgbox(64,"Closed ...","Window Media Player was closed at : " & $hrs,3) endif [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Senrathy Posted March 10, 2008 Author Share Posted March 10, 2008 (edited) I tried the two codes, but the window still dont close :/ And i need the script running every day, nonstop. It close the window and then re-execute itself for another close on another day. Get it? I dont know what is wrong, so here is my code: expandcollapse popuptSetOption("MustDeclareVars", True) ; Tempo de espera entre novas tentativas de abrir o video (em minutos) Dim $INTERVALO_ERRO = 5 ; Config do media player classic Dim $PLAYER = "mplayerc.exe" Dim $PLAYER_TOCAR = "/play" Dim $PLAYER_TELA_CHEIA = "/fullscreen" Dim $ARQUIVOS = "c:\videos\video01.wmv" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Play the video until the computer shutdown Dim $PARAMETROS = $PLAYER_TOCAR & " " & $PLAYER_TELA_CHEIA & " " & $ARQUIVOS; Dim $SUCESSO = 0 While True Dim $RESULTADO = ShellExecuteWait($PLAYER, $PARAMETROS) If $RESULTADO <> $SUCESSO Then Sleep(1000 * 60 * $INTERVALO_ERRO) EndIf WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Closes the Media Player Classic at an estipulated hour Dim $closeHour = "10" Dim $closeMin = "18" Dim $timeClose = $closeHour &$closeMin Do Sleep(1000) Dim $time = @HOUR &@MIN Until $time = $timeClose ProcessClose("mplayerc.exe") Edited March 10, 2008 by Senrathy Link to comment Share on other sites More sharing options...
ssubirias3 Posted March 10, 2008 Share Posted March 10, 2008 I tried the two codes, but the window still dont close :/ And i need the script running every day, nonstop. It close the window and then re-execute itself for another close on another day. Get it? I dont know what is wrong, so here is my code: Monamo knows what he's talking about and you can trust his code to work every time. But since you say it didn't work, I'd guess the problem is with the process name you are trying to close. Make sure task manager lists "mplayerc.exe" as the actual process name. I tried the following with windows media player and it worked like a champ. ;~ Dim $closeHour = "10" ;~ Dim $closeMin = "18" Dim $timeClose = "1018" Do Sleep(30000) Dim $time = @HOUR &@MIN Until $time = $timeClose ProcessClose("wmplayer.exe") A couple of points, you don't need to have $closeHour and $closeMin to set $timeClose. Also the Sleep(1000) is pausing the script for 1 second. Since you are trying to close the program at a specific hour and minute, there isn't a need to check the time every second. The Sleep(30000) checks the time every 30 seconds and is easier on your computer. Hope this helps and good luck. Link to comment Share on other sites More sharing options...
Senrathy Posted March 10, 2008 Author Share Posted March 10, 2008 (edited) Thx!!! ;D It helped a lot! The code was right, but when I combined it with my previous one, it just dont run :/ So, i´ve created another script with this code and one with my previous code, and worked great! ;D And added @SEC to be more precise. Added a "Do" command to make it loop forever, so it wont close ´till the variable $time was equal to 25 ;D and it will never be 25 thx for the tips This forum rlz! Edited March 10, 2008 by Senrathy Link to comment Share on other sites More sharing options...
LinuZ Posted March 10, 2008 Share Posted March 10, 2008 Nice script Manamo, and good explained ssubirias3 I think I will have use to this too! 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