kayser2008 Posted October 31, 2011 Posted October 31, 2011 I have made a script with help of some foruns of autoit but i can´t had this function to the script wath i need to do is every time the time get´s to 00:00:00 the p.c reboots for the deepfreze takes efect but i´am having dificulty to implante this function in my script can anyone give me a clue. func Shutdown(2) Hi will post the script i apreceat if someone give me a clue.coinkiosk.au3
GEOSoft Posted November 1, 2011 Posted November 1, 2011 You are not giving us much to go on here. You did say that you would post the code you tried. If you want the Script to always be running in the background and restart the system at midnight then use something like this While 1 If @Hour = 0 And @Min = 0 AND @Sec <= 3 Then ExitLoop EndIf Sleep(250) WEnd ShutDown(6) ;; Change the 6 to a 2 if you don't want to force it Of course if you would show what you have attempted so we can get a clearer idea of what you want; we may be able to come up with a better solution. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Spiff59 Posted November 1, 2011 Posted November 1, 2011 (edited) Been posting and reposting for 20 minutes now... very interesting... Including this line in CODE tags trashes the post: sleep(1000); ajuste este tempo de acordo com o pulso do seu moedeiro, terá que ser menor que o pulso #include <Date.au3> Global $Curdate = _NowDate While 1 ;... ;... ;... ;... sleep(1000) If $Curdate <> _NowDate() Then Shutdown(2) Wend $JOYINFO = 0 Exit(0) Must be the funny accented unicode "a" that's the culprit... Edited November 1, 2011 by Spiff59
kayser2008 Posted November 1, 2011 Author Posted November 1, 2011 (edited) This is a script with a cowntdown timer for a internet kiosk wath i want is a way to incorporate the funcion Shutdown(2) in the script that avery time the time is over the computer will be restarted i have allready try to do it but the computer is restarting over and over again and if can give me an idea to optimaize my script. Best regards expandcollapse popup#include <GUIConstants.au3> #Include <WinAPI.au3> ProgressOn("A Carregar", "Abrir", "0%") For $i = 10 To 100 Step 10 Sleep(1000) ProgressSet($i, $i & "%") Next ProgressSet(100, "Carregado", "Completo") Sleep(500) ProgressOff() Local $comprimento = iniRead(".\Contador.ini", "Janela do Contador regressivo", "comprimento", ""); pega os dados do arquivo ini Local $altura = iniRead(".\Contador.ini", "Janela do Contador regressivo", "altura", ""); pega os dados do arquivo ini Local $horizontal = iniRead(".\Contador.ini", "Janela do Contador regressivo", "Horizontal", ""); pega os dados do arquivo ini Local $vertical = iniRead(".\Contador.ini", "Janela do Contador regressivo", "Vertical", ""); pega os dados do arquivo ini Local $fonte = iniRead(".\Contador.ini", "Janela do Contador regressivo", "Fonte Usada", ""); pega os dados do arquivo ini Local $font_size = iniRead(".\Contador.ini", "Janela do Contador regressivo", "Tamanho da fonte", ""); pega os dados do arquivo ini Local $bot_credito = iniRead(".\Contador.ini", "Botão usado para creditar tempo", "Creditar", ""); pega os dados do arquivo ini Local $JOYID = IniRead(".\contador.ini", "Identifica joy", "Id joy", ""); identifica qual joystick será usado Local $tempo, $temporizador, $horas, $minutos, $segundos; variáveis globais Local $JOYINFO, $bt_joy, $str $str = "int x;int y;int z;int buttons" $JOYINFO = DllStructCreate($str) $hWnd = WinGetHandle("[CLASS:Shell_TrayWnd]"); identifica a barra _WinAPI_ShowWindow($hWnd, @SW_SHOW); mostra a barra de tarefas AdlibRegister("sistema", 1000); Ajuste o tempo de acordo com o pulso do seu moedeiro While 1 $retjoy = DllCall("winmm.dll", "int", "joyGetPos", "int", $JOYID, "ptr", DllStructGetPtr($JOYINFO)) $bt_joy = DllStructGetData($JOYINFO, "buttons");pega os valores preenchidos pela função JoyGetPos If BitAND($bt_joy, $bot_credito) Then creditar(); chama a função creditar Endif If WinExists("Gestor de tarefas do Windows") Then ; verifica se a janela existe WinClose("Gestor de tarefas do Windows"); fecha o Gestor de tarefas MsgBox("", "", "Bloqueado pelo Administrador", 3); mostra a mensagem Endif If WinExists("Centro de ajuda e suporte")Then;verifica se a janela existe WinClose("Centro de ajuda e suporte");fecha o Centro de ajuda e suporte MsgBox("","","Bloqueado pelo Administrador",3);mostra a mensagem EndIf $tempo = IniRead(".\contador.ini", "Tempo Restante", "Restando", ""); pega a informação de fichas do arquivo ini $temporizador = "00:00:00"; formato do contador $horas = Int($tempo / 3600000); converte o valor em horas $minutos = Int(Mod($tempo, 3600000) / 60000); converte o valor em minutos $segundos = Int(Mod(Mod($tempo, 3600000), 60000) / 1000); converte o valor em segundos $temporizador = StringFormat("%02d:%02d:%02d", $horas, $minutos, $segundos); informações que serão mostradas no contador SplashTextOn("Tempo", "" & $temporizador, 115, 35, 4, 2, 300, "Bernard MT Condensed", 18); mostra o contador sleep(1000); ajuste este tempo de acordo com o pulso do seu moedeiro, terá que ser menor que o pulso Wend $JOYINFO = 0 Exit(0) func sistema() if $tempo >= 1000 then; verifica se o tempo chegou a 1 segundo se estiver em "0" para de gravar $diminui = (Number($tempo) - 1000); diminui 1 segundo IniWrite(".\contador.ini", "Tempo Restante", "Restando", ($diminui)); grava o tempo com 1 segundo a menos endif if $tempo <= 0 then; quando chegar a "0" Bloqueia o teclado BlockInput(0) endif if $tempo < 1 then ProcessClose("firefox.exe") endif If $tempo < 1 Then ProcessClose("msnmsgr.exe") endif if $tempo > 1 then; se o tempo for maior que "0" libera o teclado BlockInput(0); libera o teclado endif endfunc ;==>sistema func creditar() Local $valor_ficha, $converte, $tempo_rest, $adiciona Local $JOYID = IniRead(".\contador.ini", "Identifica joy", "Id joy", ""); identifica qual joystick será usado Local $JOYINFO, $bt_joy, $str Local $bot_credito = iniRead(".\Contador.ini", "Botão usado para creditar tempo", "Creditar", ""); pega os dados do arquivo ini $str = "int x;int y;int z;int buttons" $JOYINFO = DllStructCreate($str) While 1 $retjoy = DllCall("winmm.dll", "int", "joyGetPos", "int", $JOYID, "ptr", DllStructGetPtr($JOYINFO)) $bt_joy = DllStructGetData($JOYINFO, "buttons") ;pega os valores preenchidos pela função JoyGetPos If not BitAND($bt_joy, $bot_credito) Then ; credita somente quando o botão for solto $valor_ficha = IniRead(".\contador.ini", "Tempo que vale 1 ficha", "Tempo em minutos", ""); valor em minutos de 1 ficha $converte = (Number($valor_ficha) * 60000); converte o tempo que vale a ficha para milisegundos $tempo_rest = IniRead(".\contador.ini", "Tempo Restante", "Restando", ""); lê no contador.ini $adiciona = (Number($tempo_rest) + Number($converte)); soma o valor da ficha ao tempo restante IniWrite(".\contador.ini", "Tempo Restante", "Restando", String($adiciona)); grava no contador.ini ExitLoop endif sleep(20) Wend endfunc ;==>creditar Edited November 1, 2011 by kayser2008
shornw Posted November 2, 2011 Posted November 2, 2011 Without running your script, I see there is an Exit(0) command in your script... if this exits the program, can't you replace it with a ShutDown(6) to force a reboot. If you need to use the return code to identify completion of the script, you could call another script which writes the ErrorLevel to a log, then forces a restart of the PC [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
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