Auto-Process

Aquí pueden poner todos los programas y utilidades que hayan creado con AMS.
Auto-Process

Información:
Auto-Process es una pequeña aplicación que he creado que no tiene entorno alguno simplemente se aloja en área de notificación desde donde se gestiona solo sirve para dos cosas muy simples apagar y reiniciar el ordenador para ello he usado shutdown.exe que trae windows, no le he puesto muchas milongas así que es bien simple, seleccionas el tiempo que deseas y la función y en X tiempo mas 1 minuto se reinicia el ordenador... esto es por que shutdown añade un minuto desde que es ejecutado...

Aquí os dejo mas información sobre shutdown.exe:

Código: Seleccionar todo

http://es.wikihow.com/usar-el-comando-shutdown-en-Windows
Código:
-- GLOBAL:
function DestroyIcon()
	if (HTray ~= 0) then
		Tray.DestroyIcon(HTray);
		local  bDestroyed = Tray.Destroy(HTray);
		if (bDestroyed == false) then
			Dialog.Message("Error", "Fallo al eliminar el icono del area de notifdicación.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
		end
	end
end

function TrayIconCallBack(strMouseEvent)
    -- available mouse events for callback function 

    -- "WM_LBUTTONDOWN"
    -- "WM_LBUTTONUP"
    -- "WM_LBUTTONDBLCLK"
    -- "WM_RBUTTONDOWN"
    -- "WM_RBUTTONUP"
    -- "WM_RBUTTONDBLCLK"
    -- "WM_MBUTTONDOWN"
    -- "WM_MBUTTONUP"
    -- "WM_MBUTTONDBLCLK"
    
	if (strMouseEvent == "WM_LBUTTONUP") or (strMouseEvent == "WM_RBUTTONUP") then
		ShowTrayMenu();
		
	elseif (strMouseEvent == "WM_LBUTTONDBLCLK") then
		if setVar == nil then
			setVar = true
			Window.Restore(Application.GetWndHandle());
		else
			Window.Minimize(Application.GetWndHandle());
			Window.Hide(Application.GetWndHandle()); 
			setVar = nil;
		end
	end
end

function MinimizeToTray()
	if (HTray ~= 0) then
		Window.Minimize(Application.GetWndHandle()); -- just for minimize effect
		Window.Hide(Application.GetWndHandle()); -- then hide it
		local bBalloon = Tray.ShowBalloonTip(HTray, "Minimizado al Area de Notificación", "Hey .. Si quieres algo estoy aquí abajo esperandote, si desea cerrar la aplicación haga clic derecho a este icono y seleccione 'Salir'", 5000, NIIF_NONE);
	end   
end

function QueryAllowProjectClose()
   MinimizeToTray();
   return false  
end

function ShowTrayMenu()
	---------------------------------------------------------
	-- Reiniciar en
	---------------------------------------------------------
	tblMenu = {};
	tblMenu[1] ={};
	tblMenu[1].Text = "Reiniciar en";
	tblMenu[1].ID = 100;
	tblMenu[1].IconID = 0;
	tblMenu[1].Checked = false;
	if StartedTimer == nil then
		tblMenu[1].Enabled = true;
	else
		tblMenu[1].Enabled = false;
	end
	tblMenu[1].SubMenu = {};
	
	PR = 0;
	VarMin = 0;
	repeat
		PR = PR + 1;
		VarMin = VarMin + 5;
		tblMenu[1].SubMenu[PR] ={};
		tblMenu[1].SubMenu[PR].Text = VarMin.." Minutos";
		
		if PR > 9 then
			tblMenu[1].SubMenu[PR].ID = (1)..PR;
		else
			tblMenu[1].SubMenu[PR].ID = (10)..PR;
		end
		
		tblMenu[1].SubMenu[PR].IconID = 0;
		tblMenu[1].SubMenu[PR].Checked = false;
		tblMenu[1].SubMenu[PR].Enabled = true;
		if PR == 12 then
			tblMenu[1].SubMenu[13] ={};
			tblMenu[1].SubMenu[13].Text = "Personalizado";
			tblMenu[1].SubMenu[13].ID = 113;
			tblMenu[1].SubMenu[13].IconID = 0;
			tblMenu[1].SubMenu[13].Checked = false;
			tblMenu[1].SubMenu[13].Enabled = true;		
		end
	until PR == 12;
	
	---------------------------------------------------------
	-- Apagar en
	---------------------------------------------------------
	tblMenu[2] ={};
	tblMenu[2].Text = "Apagar en";
	tblMenu[2].ID = 101;
	tblMenu[2].IconID = 0;
	tblMenu[2].Checked = false;
	if StartedTimer == nil then
		tblMenu[2].Enabled = true;
	else
		tblMenu[2].Enabled = false;
	end
	tblMenu[2].SubMenu = {};
	
	PR = 0;
	VarMin = 0;
	repeat
		PR = PR + 1;
		VarMin = VarMin + 5;
		tblMenu[2].SubMenu[PR] ={};
		tblMenu[2].SubMenu[PR].Text = VarMin.." Minutos";
		
		if PR > 9 then
			tblMenu[2].SubMenu[PR].ID = (2)..PR;
		else
			tblMenu[2].SubMenu[PR].ID = (20)..PR;
		end
		
		tblMenu[2].SubMenu[PR].IconID = 0;
		tblMenu[2].SubMenu[PR].Checked = false;
		tblMenu[2].SubMenu[PR].Enabled = true;
		if PR == 12 then
			tblMenu[2].SubMenu[13] ={};
			tblMenu[2].SubMenu[13].Text = "Personalizado";
			tblMenu[2].SubMenu[13].ID = 213;
			tblMenu[2].SubMenu[13].IconID = 0;
			tblMenu[2].SubMenu[13].Checked = false;
			tblMenu[2].SubMenu[13].Enabled = true;
		end
	until PR == 12;
	

	---------------------------------------------------------
	-- Programador Actual
	---------------------------------------------------------		
	tblMenu[3] ={};
	tblMenu[3].Text = "Programador ";
	tblMenu[3].ID = 300;
	tblMenu[3].IconID = 0;
	tblMenu[3].Checked = false;
	if StartedTimer == nil then
		tblMenu[3].Enabled = false;
	else
		tblMenu[3].Enabled = true;
	end
	tblMenu[3].SubMenu = {};
	tblMenu[3].SubMenu[1] ={};
	tblMenu[3].SubMenu[1].Text = "Mostrar Tiempo";
	tblMenu[3].SubMenu[1].ID = 301;
	tblMenu[3].SubMenu[1].IconID = 0;
	tblMenu[3].SubMenu[1].Checked = false;
	tblMenu[3].SubMenu[1].Enabled = true;
	tblMenu[3].SubMenu[2] ={};
	tblMenu[3].SubMenu[2].Text = "Parar";
	tblMenu[3].SubMenu[2].ID = 302;
	tblMenu[3].SubMenu[2].IconID = 1;
	tblMenu[3].SubMenu[2].Checked = false;
	tblMenu[3].SubMenu[2].Enabled = true;
	
	---------------------------------------------------------
	-- Acerca de...
	---------------------------------------------------------		
	tblMenu[4] ={};
	tblMenu[4].Text = "Acerca de...";
	tblMenu[4].ID = 400;
	tblMenu[4].IconID = 2;
	tblMenu[4].Checked = false;
	tblMenu[4].Enabled = true;	
	---------------------------------------------------------
	-- Salir
	---------------------------------------------------------	
	tblMenu[5] ={};
	tblMenu[5].Text = "Salir";
	tblMenu[5].ID = 500;
	tblMenu[5].IconID = 3;
	tblMenu[5].Checked = false;
	tblMenu[5].Enabled = true;
	
	ptMouse = System.GetMousePosition(false, nil);
	
	nRes = Application.ShowPopupMenu(ptMouse.X, ptMouse.Y, tblMenu, TPM_RIGHTALIGN, TPM_TOPALIGN, true, false);
	
	if nRes ~= 0 and nRes ~= 100 and nRes ~= 200 and nRes ~= 300 and nRes ~= 301 and nRes ~= 302 and nRes ~= 400 and nRes ~= 500 then
		if nRes ~= 113 and nRes ~= 213 then
			Time = tonumber(String.Right(nRes, 2));
			RealTime = Time*5
			TotalTime = RealTime*60	
			Process = OneTwo(nRes);
		elseif nRes == 113 or nRes == 213 then
			TotalTime = Dialog.Input("Personalizado", "¿Cuantos minutos? (Solo pon NUMEROS)", "", MB_ICONQUESTION);
			if (TotalTime ~= "") and (TotalTime ~= "CANCEL") then
				TotalTime = tonumber(TotalTime)
				TotalTime = TotalTime*60
				Process = OneTwo(nRes);
			end
		end
	
	elseif nRes == 301 then
		TimeLeft();
	elseif nRes == 302 then
		Page.StopTimer(1);
		StartedTimer = nil;
	elseif nRes == 400 then
		Window.Restore(Application.GetWndHandle());
	elseif nRes == 500 then
		DestroyIcon();
		Application.Exit(0);
	end
end


function TimeLeft(TimeLeftOne)
	local toast_width = 450;
	local toast_height = 150;
	local estimated_taskbar_height = 40;
	local tbDispInfo = System.GetDisplayInfo();
	
	local tblOverlayWndProps = {}
	
	tblOverlayWndProps.X				= tbDispInfo.Width - 5 - toast_width;
	tblOverlayWndProps.Y				= tbDispInfo.Height - estimated_taskbar_height - 5 - toast_height;
	tblOverlayWndProps.Width			= toast_width;
	tblOverlayWndProps.Height			= toast_height;
	tblOverlayWndProps.FadeIn			= false;
	tblOverlayWndProps.FadeOut			= false;
	tblOverlayWndProps.CloseOnClick		= true;
	tblOverlayWndProps.TextColor		= 192;
	if TimeLeftOne == nil then
		tblOverlayWndProps.Text				= SecToTime(TotalTime).." para "..Traduccion(Process).." el cpu.";
	else
		tblOverlayWndProps.Text				= "ATENCION!!!! el ordenador se\r\n"..Traduccion(Process).." en 60 segundos.";
	end
	tblOverlayWndProps.FontFace			= "Arial";
	tblOverlayWndProps.FontSize			= 20;
	tblOverlayWndProps.Bold				= true; 
	tblOverlayWndProps.Italic			= false; 
	tblOverlayWndProps.Underline		= false; 
	tblOverlayWndProps.StrikeOut		= false;
	tblOverlayWndProps.TextAlign		= 0; -- 0:left 1:center 2:right
	tblOverlayWndProps.Opacity			= 230; -- 0 - 255
	tblOverlayWndProps.BackColor		= 2105376;
	tblOverlayWndProps.TextGlowSize		= 0; -- 0 - 10 | a value greater than 10 will be accepted as 0
	tblOverlayWndProps.TextGlowColor	= 12632256;
	tblOverlayWndProps.TimeOut			= 4000; -- in milliseconds
	tblOverlayWndProps.BackImage		= "";
	tblOverlayWndProps.CornerRadius		= 20;
	
	tblOverlayWndProps.Icon				= _SourceFolder.."\\AutoPlay\\Images\\"..Process..".png";
	tblOverlayWndProps.IconX			= 10;
	tblOverlayWndProps.IconY			= 10;
	tblOverlayWndProps.IconWidth		= 0;
	tblOverlayWndProps.IconHeight		= 0;
	tblOverlayWndProps.TextX			= 138;
	
	local bShowing = ScreenOverlay.Showing(ToasterHandle);
	
	if(bShowing == true) then -- close existing instance if exist
		ScreenOverlay.Close(ToasterHandle);
	end
		
	ToasterHandle = ScreenOverlay.Show(tblOverlayWndProps);
	
	if(ToasterHandle == 0) then
		 Dialog.Message("Error", "Failed to create overlay window.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
	end
end

function Traduccion(var1)
	if var1 == "Restart" then
		var1 = "reiniciar"
	elseif var1 == "Shutdown" then
		var1 = "apagar"
	end
	return var1
end

function OneTwo(nRes)
	UnoDos = String.Left(nRes, 1);
	if UnoDos == "1" then
		Process = "Restart";
		Page.StartTimer(1000, 1);
	elseif UnoDos == "2" then
		Process = "Shutdown";
		Page.StartTimer(1000, 1);
	end
	return Process;
end
			
function SecToTime(numSec)
	local numSec = Math.Round(numSec, 0)
	local min = Math.Floor(numSec/60);
	local hour = Math.Floor(numSec/3600);
	local sec = numSec - min*60
	if (String.Length(min) == 1) then
		min = "0"..min
	end
	if (String.Length(sec) == 1) then
		sec = "0"..sec
	end	
	if (hour == 0) then
		return min..":"..sec;
	else
		min = min - hour*60
		if (String.Length(min) == 1) then
			min = "0"..min
		end
		return hour..":"..min..":"..sec;
	end
end
-- ON PRELOAD
HTray = Tray.Create(1000, "TrayIconCallBack");
if (HTray ~= 0) then		
	bIconAdded = Tray.SetIcon(HTray, "", "Tray Action Plugin Demo");	
	if (bIconAdded == false) then
		Dialog.Message("Error", "Fallo al añadir el icono al area de notificación.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
	end	
end
-- ON SHOW
MinimizeToTray();
-- ON TIMER
if e_ID == 1 then
	if StartedTimer == nil then
		StartedTimer = true;
	end
	TotalTime = TotalTime - 1;
	if TotalTime == 0 then
		Page.StopTimer(1);
		if Process == "Restart" then
			result = Shell.Execute(_WindowsFolder.."\\System32\\shutdown.exe", "open", "-r", "", SW_SHOWNORMAL, false);
		else
			result = Shell.Execute(_WindowsFolder.."\\System32\\shutdown.exe", "open", "-s", "", SW_SHOWNORMAL, false);
		end
	elseif TotalTime == 60 then
		TimeLeft(true);
	end
end
-- BOTONES:
-- XBUTTON1
--MinimizeToTray();
DestroyIcon();
Application.Exit(0); 
-- XBUTTON2
MinimizeToTray();
Descargas:
HIDE: ON
Hidebb Message Hidden Description


Cualquier error o duda este es el post mas adecuado para informar, gracias y un saludo!
Lo probare

gracias!!!

Thank you

Thank you

Gracias!

oh nix

Interesante

Para que sea instantaneo la orden seria:

Para Apagar:
Shell.Execute("shutdown.exe", "open", "-f -h -t 00", "", SW_HIDE, false);
Para Reiniciar:
Shell.Execute("shutdown.exe", "open", "-f -r -t 00", "", SW_HIDE, false);
Esto es para windows 7 y 8 sistemas anteriores es:

Para Apagar:
Shell.Execute("shutdown.exe", "open", "/f /h /t 00", "", SW_HIDE, false);
Para Reiniciar:
Shell.Execute("shutdown.exe", "open", "/f /r /t 00", "", SW_HIDE, false);

:num1: :num1: :num1:

This would of been useful on my old windows 8 setup my PC and windows 8 power managmernt don't work right and I could only shutdown via calling that exe via cmd.

thanks

graciasss

gracias

Gracias! andaba buscando algo asi...

:pc: :pc: :pc: :pc: :pc: :pc:

Thank you

:yes: :yes: :yes:
i'm korean

i'm can not little speaking english ㅠㅠ

how file download please~

Haut
Réponse rapide