Vypnout pc

Vypnout pc

Vypnout pc je jednoduchý prográmek, který vypne pc za zadaný čas.

Zdrojový kód

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=vp.ico
#AutoIt3Wrapper_Res_Comment=VypnoutPC
#AutoIt3Wrapper_Res_Description=VypnoutPC
#AutoIt3Wrapper_Res_Fileversion=2015.12.23.1
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt("TrayIconHide", 1)
Local $input, $updown, $msg, $vypnout, $storno, $min, $odpocet
Local $begin = "nic", $begin2
GUICreate("Vypnout pc", 226, 50)
GuiCtrlCreateLabel("za", 20, 17)
$input = GUICtrlCreateInput(15, 40, 14, 50, 20)
$updown = GUICtrlCreateUpdown($input)
$min = GuiCtrlCreateLabel("min", 94, 17)
$vypnout = GuiCtrlCreateButton("Vypnout", 120, 13, 60, 22)
$odpocet = GuiCtrlCreateLabel("", 40, 17, 80, 20)
$storno = GuiCtrlCreateButton("Storno", 120, 13, 60, 22)
GUICtrlSetState ( $odpocet, $GUI_HIDE )
GUICtrlSetState ( $storno, $GUI_HIDE )
GUISetState()
While 1
	$msg = GUIGetMsg()
	If $msg = $vypnout Then
		$begin = TimerInit()
		GUICtrlSetState ( $input, $GUI_HIDE )
		GUICtrlSetState ( $updown, $GUI_HIDE )
		GUICtrlSetState ( $vypnout, $GUI_HIDE )
		GUICtrlSetState ( $min, $GUI_HIDE )
		GUICtrlSetState ( $odpocet, $GUI_SHOW )
		GUICtrlSetState ( $storno, $GUI_SHOW )
	EndIf
	If $msg = $storno Then
		$begin = "nic"
		GUICtrlSetData ($input,15)
		GUICtrlSetState ( $min, $GUI_SHOW )
		GUICtrlSetState ( $input, $GUI_SHOW )
		GUICtrlSetState ( $updown, $GUI_SHOW )
		GUICtrlSetState ( $vypnout, $GUI_SHOW )
		GUICtrlSetState ( $odpocet, $GUI_HIDE )
		GUICtrlSetState ( $storno, $GUI_HIDE )
	EndIf
	If TimerDiff($begin2) > 200 And $begin <> "nic" And TimerDiff($begin) + 60000 < GUICtrlRead($input)*60000 Then
	GUICtrlSetData ($odpocet, Floor (GUICtrlRead($input) - TimerDiff($begin)/60000) & " min")
	$begin2 = TimerInit()
	EndIf
	If TimerDiff($begin2) > 200 And $begin <> "nic" And TimerDiff($begin) + 60000 > GUICtrlRead($input)*60000 Then
		GUICtrlSetData ($odpocet, Floor (GUICtrlRead($input)*60 - TimerDiff($begin)/1000) & " s")
		$begin2 = TimerInit()
	EndIf
	If $begin <> "nic" And TimerDiff($begin) > GUICtrlRead($input)*60000 Then
		$begin = "nic"
		If ProcessExists ("firefox.exe") Then
			If WinActive("[CLASS:MozillaWindowClass]") Then
				Send("{ESC}")
				Sleep (2000)
				Send("!{F4}");~ProcessClose ("firefox.exe")
				Sleep(2000)
			EndIf
		EndIf
		Shutdown(9)
	EndIf
	If GUICtrlRead($input) < 1 Then	GUICtrlSetData ($input,1)
	If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd