Cronómetro que luego cierre un block de notas

Esta sección es para preguntas sobre programación/scripting usando AutoHotkey.

Moderator: Flipeador

cracking
Posts: 1
Joined: 24 Apr 2022, 15:37

Cronómetro que luego cierre un block de notas

Post by cracking » 24 Apr 2022, 15:44

me podrian ayudar con un crono metro que se inicie con 5 minutos y si preciona la tecla 1 aumente otros 5 mnts y cuando el cronometro llegue a cero que se cierre un block de notas

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Contador de tiempo ejecución del programa

Post by flyingDman » 24 Apr 2022, 16:32

Code: Select all

1::
time += 300000                                           ; = 5 * 60 * 1000 
settimer, lbl, 1000
return

lbl:
time -= 1000
tooltip, % (time // 60000) ":" round(mod(time,60000)/1000,0)
if (time = 0)
	{
	Msgbox Cualquier acción aquí
	exitapp
	}
return

esc::
exitapp
14.3 & 1.3.7

User avatar
ositoMalvado
Posts: 182
Joined: 24 Dec 2019, 12:02
Contact:

Re: Cronómetro que luego cierre un block de notas

Post by ositoMalvado » 17 Aug 2022, 17:56

Estimado compañero,
le presento la solución que realicé para su problema,
puede configurar algunas cosas para lograr adaptarlo a su gusto,
espero que le sirva.

Code: Select all

;VARIABLES CONFIGURABLES - - - inicia
;
;
    global PROGRAMA_A_CERRAR := "notepad.exe" ;programa que cerrara el script
    global TIEMPO_INICIAL = 10 ;segundos, 300 = 5 minutos
    global TIEMPO_AGREGAR = 5 ;segundos, 60 = 1 minuto
    global INFO = true ;mostrar tiempo que queda para cerrar programa
    global SONIDO_TICK := true ;sonará cada segundo si está en true, false = sin sonido
    global SONIDO := "https://lithi.io/file/vsss.wav" ;link el sonido del tick a usar
;
;
;VARIABLES CONFIGURABLES - - - finaliza

;VARIABLES EXTRA + DESCARGA DE SONIDO - - - inicia
;
;
global TIEMPO
global ENCENDIDO:=false
if SONIDO_TICK
    while (!FileExist(A_ScriptDir "\tick.wav"))
        UrlDownloadToFile, % SONIDO, % A_ScriptDir "\tick.wav"
;
;
;VARIABLES EXTRA + DESCARGA DE SONIDO - - - finaliza
Return ;finaliza inicialización de programa


#n:: ;al apretar Telca Windows + N se iniciara un contador para cerrar el programa, al presionar nuevamente mientras, está encendido se agregara tiempo al contador
    if WinExist("ahk_exe " PROGRAMA_A_CERRAR){
        if(!ENCENDIDO){
            if INFO
                SetTimer, infoMouse, 5
            TIEMPO:=TIEMPO_INICIAL*1000
            SetTimer, cerrarNotepad, On
        }else{
            TIEMPO+=TIEMPO_AGREGAR*1000
        }
        ENCENDIDO:=true
    }
Return


cerrarNotepad: ;funcion para cerrar el notepad y/o script
    if (TIEMPO<=0||!WinExist("ahk_exe " PROGRAMA_A_CERRAR)){
        While WinExist("ahk_exe " PROGRAMA_A_CERRAR){
            Process,Close,notepad.exe
        }
        SetTimer, cerrarNotepad, off
        if INFO{
            Gosub, borrarInfo
            SetTimer, infoMouse, off
        }
        ENCENDIDO:=false
        Return
    }
    TIEMPO-=1000
    SoundPlay, % A_ScriptDir "\tick.wav"
    Sleep, 1000
Return


infoMouse: ;mostrar info de tiempo hasta cerrar programa
    MouseGetPos, mx, my
    ToolTip, % "Quedan "Round(TIEMPO/1000) " segundos para cerrar notepad.exe", % mx+30, % my+5
    SetTimer, borrarInfo, 100
Return

borrarInfo: ;eliminar información
    ToolTip
Return
My WEB some useful stuff

Post Reply

Return to “Pedir Ayuda”