Cronómetro que luego cierre un block de notas

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Cronómetro que luego cierre un block de notas

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

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

Re: Contador de tiempo ejecución del programa

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

Cronómetro que luego cierre un block de notas

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

Top