Utilities Action Plugin

Description

This is a collection of actions built into a small plugin (currently at 125 kB for the x86 version), adding several useful functions to the toolbox of Setup Factory or AutoPlay Media Studio.

Actions

Utilities.FolderBrowse(string Prompt, string DefaultFolder);

Description:

This action is similar to the built-in Dialog.FolderBrowse(), however it allows to select multiple folders instead of just a single one.

Prompt

(string) The message text on the dialog.

DefaultFolder

(string)The default folder to browse.

Returns:

(table) A table with the paths to the folders that were selected with the folder browse dialog. If the user cancels the operation (presses the cancel button), the string "CANCEL" will be returned in the first position of the table. If an error occurs, a blank string "" will be returned. You can use Application.GetLastError to determine whether this action failed, and why.

Example:

local tFolders = Utilities.FolderBrowse("Select Folder(s)", Shell.GetFolder(SHF_MYDOCUMENTS));
if (tFolders[1] ~= "CANCEL") then
	local sMsg = "";
	for i=1, Table.Count(tFolders) do
		sMsg = sMsg .. tFolders[i] .. "\r\n";
	end
	Dialog.Message("Result", "You selected:\r\n" .. sMsg, MB_OK, MB_ICONINFORMATION);
end

Utilities.GetHDInfo();

Description:

Returns the model and the serial number of the first hard drive (Disk 0) installed on the computer.

Returns:

(table) The hard drive model will return as the index "Model", and the serial number as the index "Serialnumber".

Example:

local tHardDriveInfo = Utilities.GetHDInfo();

Dialog.Message("Hard drive", "Model: " .. tHardDriveInfo.Model .. "\r\nSerial number: " .. 
	tHardDriveInfo.Serialnumber, MB_OK, MB_ICONINFORMATION);

This script could return a result similar to this:

Utilities.GetLnkTarget(string Filename);

Description:

Retrieves the target and the arguments for a shortcut file (*.lnk) on the user's system.

Filename:

(string) The full path to the shortcut file.

Returns:

(table) The target of the shortcut will return as the index "Target", and the arguments as the index "Arguments". You can use Application.GetLastError to determine whether this action failed, and why.

Example:

-- Shortcut for IE set up for InPrivate browsing
local sDesktop = Shell.GetFolder(SHF_DESKTOP);
local tShortcut = Utilities.GetLnkTarget(sDesktop .. "\\Internet Explorer.lnk");
error = Application.GetLastError();
if (error ~= 0) then
	Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
	Dialog.Message("Shortcut", "Target: " .. tShortcut.Target .. "\r\nArguments: " .. tShortcut.Arguments, 
		MB_OK, MB_ICONINFORMATION);
end

This script could return a result similar to this:

Utilities.MessageBoxEx(string Title, string Message, string Checkbox, number Type);

Description:

This action allows the creation of a MessageBox with a Checkbox on it. Typically this is used to show a message to the user, with the option to hide further dialogs.

Title

(string) The text that will appear in the dialog title bar..

Message

(string) The text that will appear on the dialog.

Checkbox

(string) The caption of the checkbox that will appear on the dialog.

Type

(number) The type of the MessageBox to be displayed. Allowed values are MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNOCANCEL, MB_YESNO, MB_RETRYCANCEL

Icon

(number) The icon to display on the dialog. Allowed values are MB_ICONNONE, MB_ICONSTOP, MB_ICONQUESTION, MB_ICONEXCLAMATION, MB_ICONINFORMATION

DefaultButton

(number) The button that will get the focus by default. Possible values are MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3

Checked

(boolean) Whether the checkbox should be checked by default when the dialog is displayed or not.

Returns:

(number) The numeric constant for the button that was pressed:

CONSTANTVALUEDESCRIPTION
IDOK1The OK button.
IDCANCEL2The Cancel button.
IDABORT3The Abort button.
IDRETRY4The Retry button.
IDIGNORE5The Ignore button.
IDYES6The Yes button.
IDNO7The No button.

If the checkbox was marked, then 16 will be added to the constant. For example, IDOK + checkbox = 17.

Example:

-- display a message with a checkbox
nRes = Utilities.MessageBoxEx("Messagebox with an option", "This program is working perfectly.", 
    "Do not show this again", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1, false);
if (nRes > 16) then
    -- the checkbox was selected, process the input as required
end

This script could return a result similar to this:

Utilities.MinimizeToTray(number Window);

Description:

Hides the application window and creates an icon in the system tray instead. This can be used to temporarily remove the application from the taskbar, while it is processing something. Use Utilities.RemoveFromTray() to move back to taskbar, as in the example below.

Window

The handle to the main application window to be minimized.

Returns:

(nothing)

Example:

-- get handle on the current window
local hWnd = Application.GetWndHandle();
-- minimize application to taskbar
Window.Minimize(hWnd);
-- remove the icon from the taskbar, moving to tray
Utilities.MinimizeToTray(hWnd);
-- some delay for dramatic effect
Application.Sleep(5000);
-- restore application window on the desktop
Window.Restore(hWnd);
-- move the window to front
Window.SetOrder(hWnd,  HWND_TOPMOST);
-- remove the icon from tray back to the taskbar
Utilities.RemoveFromTray();

Utilities.RemoveFromTray();

Description:

Removes the icon from tray and shows the application window again.

Returns:

(nothing)

Utilities.RefreshWindow();

Description:

Dispatches pending WM messages, preventing user interface from becoming unresponsive.

Returns:

(nothing)

Example:

for i = 1, nLongNumber do  
    -- some really long operation here which could take a few seconds to complete
    -- place a call to the plugin to refresh the window messages queue and preventing "not responding"
    Utilities.RefreshWindow();
end

Utilities.RetrieveCertificate(string Filename);

Description:

Retrieves information about a digitally signed file. This can be used to verify if a certain file is signed, with the same certificate as expected (with the original publisher's serial name and serial number).

Filename:

(string) The full path to the signed file.

Returns:

(table) A table containing information about the certificate, or nil if there was an error or the file is not signed.

INDEXDESCRIPTION
PublisherCertSubjectThe name of the holder of the certificate (developer or company).
PublisherCertIssuerThe Certification Authority who issued the certificate.
CounterSignerCertSubjectThe Certification Authority who counter-signed (timestamped) the signature.
CounterSignerCertIssuerThe Certification Authority who issued the the certificate of the timestamper.
CounterSignerTimestampWhen the signature was countersigned (timestamped).
PublisherCertSerialThe serial number of the certificate of the software publisher.

Example:

local tFile = Dialog.FileBrowse(true, "Select a file", Shell.GetFolder(SHF_PROGRAMFILES), "All Files (*.*)|*.*|", "", "", false, true);
if (tFile[1] ~= "CANCEL") then
	Input.SetText("inpFilename", tFile[1]);
	
	local tCert = Utilities.RetrieveCertificate(tFile[1]);
	error = Application.GetLastError();

	if (tCert ~= nil) then
		Label.SetText("lblPublisherCertSubject", tCert.PublisherCertSubject);
		Label.SetText("lblPublisherCertIssuer", tCert.PublisherCertIssuer);
		if (tCert.CounterSignerCertSubject ~= nil) then
			Label.SetText("lblCounterSignerCertSubject", tCert.CounterSignerCertSubject);
			Label.SetText("lblCounterSignerCertIssuer", tCert.CounterSignerCertIssuer);
			if (tCert.CounterSignerTimestamp ~= nil) then
				Label.SetText("lblCounterSignerTimestamp", tCert.CounterSignerTimestamp);
			end
		end
		Label.SetText("lblPublisherCertSerial", "[".. tCert.PublisherCertSerial .. "]");
	else
		Dialog.Message("Error", "No valid certificate found.\r\n" .. _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);	
	end
	
end

 

Error Codes

12185 - Failed to start Utilities Actions plugin.

Additional Information

Author:

Ulrich Peters
upeters@mindquake.com.br

Copyright:

Plugin is copyright © 2021 MindQuake Serviços de Informática Ltda.

Website:

http://www.mindquake.com.br


Copyright © 2015-2021 MindQuake Serviços de Informática Ltda.
Todos os direitos reservados.