12Ghosts.com | Download | Order | Support 

12Ghosts Timer Options

12Ghosts - Timer - Timer Options

 

Command Line Parameters

There is just one command line option, /s for silent mode. This keeps the Timer from showing the Timer settings window after start. /s is used in the startup shortcut automatically.

If you don't specify any command line parameter, and Timer is already running, this command line option will cause the running instance to re-check all timer sets. This may be useful, for example, after changing registry values. Timer will re-read all registry values by just starting it again.

12-Timer supports the registry value StopTimerAfterNextStart. You can launch a program at a certain time and then stop 12-Timer.

For example, you may want to execute a program from boot-up and set 12-Timer to run this program 30 seconds after startup. Then 12-Timer could itself stop so that no other program were active except for the one started just started.

To activate this stopping feature in 12-Timer, you need to add the DWORD value "StopTimerAfterNextStart" at "HKEY_CURRENT_USER\Software\12Ghosts\Timer" and set it to 1. Just copy the following .reg snippet into a new text file (without the ----- lines) and rename it to StopTimer.reg. To disable the option use the second snippet. Don't forget an additional carriage-return (empty line) at the end of the .reg file, otherwise RegEdit doesn't accept it. You can use /s for a silent import.

--- StopTimerNext.reg ------------------------------------
REGEDIT4

[HKEY_CURRENT_USER\Software\12Ghosts\Timer]
"StopTimerAfterNextStart"=dword:00000001

----------------------------------------------------------

--- KeepTimerRunning.reg --------------------------------
REGEDIT4

[HKEY_CURRENT_USER\Software\12Ghosts\Timer]
"StopTimerAfterNextStart"=dword:00000000

----------------------------------------------------------

 

Date and Time in Parameters

When you add %date or %time in the Parameters field they will be translated to the current date or time, respectively. For example, you could have a file saved with a different name every time with C:\docs\radio%date%time.mp3. Other parameters supported are:

Parameter      Example on July 2, 2016 at 03:45:00 pm
%date 2016-Jul-29
%time 15-45-07
%d 2
%dd 02
%M 7
%MM 07
%MMM Jul
%MMMM July
%yy 16
%yyyy 2016
%H 15
%HH 15
%h 3
%hh 03
%m 45
%mm 45
%s 0
%ss 00
%t p
%tt pm

 

Registry Values

ExeDescription Up to 100 characters.
ExePath Up to 255 characters.
ExeParameters Up to 255 characters.
ExeWorkDir Up to 255 characters.
StartNextDate 'yyyy/MM/dd HH:mm:ss', 24-hour format, leading zero.
StartEverySec recurring time in seconds, 0 = not recurring (if StartNextDate empty, then after logon takes precedence).
StartSecAfterBoot     If not 0, this value will be processed, and this action takes precedence. (boot = launch of Timer = after logon if in Startup).
StartActivated 1=activated, anything else deactivated.
StartDeleteAfter 1=delete after starting once, else only deactivate.
StartWorkingOnly 1=recurring on working days only, that is, Monday through Friday, otherwise runs every day.
StartBell 1=play sound on action, otherwise no sound.
StartNotAfter 'yyyy/MM/dd HH:mm:ss', 24-hour format, leading zero.
WindowState 0=Normal, 1=Min, 2=Max, 3=No Activate, 4=Min No Activate, 5=Hidden.
PriorityLevel 0=Realtime, 1=High, 2=Normal, 3=Idle.

 

Example Registry File

Here's an example registry file that you can simply double-click in order to import the values into the registry. Copy the following lines and paste them into a new text document. Save it with the extension *.reg. After changing values, just execute 12timer.exe again (you don't need to stop it) in order to import the new settings.

A good way of using this .reg file is to call up it from your program or a batch file. You can turn timers on and off just by specifying StartActivated=0 or 1, for example. Or you can call up such a .reg file from a batch that was started by the Timer itself and change the start parameters on the fly.

REGEDIT4
 
[HKEY_CURRENT_USER\Software\12Ghosts\Timer\myNewTimer]
"ExeDescription"="This is an example reminder"
"ExePath"=""
"ExeParameters"=""
"ExeWorkDir"=""
"StartNextDate"="1998/03/12 10:20:00"
"StartEverySec"=dword:00000000
"StartSecAfterBoot"=dword:00000000
"StartActivated"=dword:00000001
"StartDeleteAfter"=dword:00000000
"StartWorkingOnly"=dword:00000000
"StartBell"=dword:00000001
"StartNotAfter"=""
"WindowState"=dword:00000000
"PriorityLevel"=dword:00000002

 

Word/Excel VBA script to add a timer

Copy the following lines to a VBA macro. Adjust the initialization at the beginning. Note the StartNextDate variable that will take the date and time for the timer.

Sub CreateTimer()
'
' Create a new reminder in 12Ghosts Timer
' Copyright © 1993-2004 12Ghosts, Inc. All rights reserved.
' Provided "AS-IS", Use at your own risk
' Initialization
' timer path
szTimerExe = "c:\program files\12ghosts\12timer.exe"
' start date
StartNextDate = "2000/10/30 10:30:00"

' temporary file
szSetFile = CurDir & "\timer.12g"

' create a new ID for the timer
Randomize
TimerID = Int(1000000000 * Rnd + 1) 'random number

'quotation marks
Q = """"

' create a text file that contains the new timer settings
Open szSetFile For Output Access Write As #1
Print #1, "REGEDIT4" ' don't change
Print #1, "" ' empty line, don't change
Print #1, "[HKEY_CURRENT_USER\Software\12Ghosts\Timer\Word" & TimerID & "]"
Print #1, Q & "ExeDescription" & Q & "=" & Q & "here goes your description" & Q
Print #1, Q & "ExePath" & Q & "=" & Q & "" & Q ' leave empty for a reminder
Print #1, Q & "ExeParameters" & Q & "=" & Q & "" & Q
Print #1, Q & "ExeWorkDir" & Q & "=" & Q & "" & Q
Print #1, Q & "StartNextDate" & Q & "=" & Q & StartNextDate & Q
Print #1, Q & "StartNotAfter" & Q & "=" & Q & "" & Q
Print #1, Q & "StartEverySec" & Q & "=" & "dword:00000000" 'a hexadecimal number
Print #1, Q & "StartSecAfterBoot" & Q & "=" & "dword:00000000"
Print #1, Q & "StartActivated" & Q & "=" & "dword:00000001" ' 0 = disable, 1 = enable
Print #1, Q & "StartDeleteAfter" & Q & "=" & "dword:00000001" ' delete after running once
Print #1, Q & "StartWorkingOnly" & Q & "=" & "dword:00000000" ' repeat Mon-Fri only
Print #1, Q & "StartBell" & Q & "=" & "dword:00000001" ' play sound
Print #1, Q & "WindowState" & Q & "=" & "dword:00000000" ' (0-5) 0 = normal
Print #1, Q & "PriorityLevel" & Q & "=" & "dword:00000002" ' (0-3) 2 = normal
Print #1, "" ' empty line, don't change
Print #1, "" ' empty line, don't change

Close #1

' import the new settings
Shell szTimerExe & " /s " & szSetFile
Kill szSetFile 'delete settings file

' execute 12timer.exe to import the changes
Shell szTimerExe

End Sub

 

Programming to the registry

If you feel comfortable programming to the registry, you'll certainly want to use the following functions.

Create a new subkey below the Timer registry key. It is advisable to use a key name that doesn't start with T, Example, or Default. For example:

HKEY_CURRENT_USER\Software\12Ghosts\Timer\MyTimerSet001\

In this key, set all or just the values you need. Just execute 12timer.exe again to import the new settings.

To do just that here is a ready to use C source code program. 1) you find the type definition of a timer set, 2) the function to create a new timer set, 3) the function to write the timer set to the registry, and 4) a function to find the install path and execute 12timer.exe to get the new subkey imported.

From a Visual Basic program you may also access the registry by declaring the WINAPI functions RegCreateKeyEx, RegSetValueEx, and RegCloseKey.

 

// --- Example on how to init and save a new timer -----
// The examples provided here are not guaranteed to work. No warranties, no liability, no guaranty for fitness of code.
// Copyright © 1993-2000 12Ghosts, Inc. on all examples and materials. All rights reserved.
// --- Declarations for 12Ghosts Timer -----
#define APPREGKEY ("Software\\12Ghosts\\Timer")

typedef struct _TimerSet { // ts set for one timer information
char SubKeyName[MAX_PATH];
char ExeDescription[101]; // max 100 (+ \0)
char ExePath[MAX_PATH];
char ExeParameters[MAX_PATH];
char ExeWorkDir[MAX_PATH];
char StartNextDate[20]; // 1998/03/12 10:20:00 max 20 (= 19 + \0)
char StartNotAfter[20];
UINT StartEverySec;
UINT StartSecAfterBoot;
DWORD StartActivated; // default: 1 = yes
DWORD StartDeleteAfter; // default: 0 = no, only deactivate
DWORD StartWorkingOnly; // default: 0 = run every day
DWORD StartBell; // default: 1 = yes, play sound
DWORD WindowState; // 0-5 default: 0, normal
DWORD PriorityLevel; // 0-3 default: 2, normal
} TIMERSET;
void main();
BOOL SetTimerSet(TIMERSET *pts);
void Start12timer();


// --- main -----------------------------
void main()
{
TIMERSET ts;
SYSTEMTIME st;

lstrcpy(ts.SubKeyName, "MyTimerSet0001");
lstrcpy(ts.ExeDescription, "Test Timer");
lstrcpy(ts.ExePath, "Notepad.exe");
ts.ExeParameters[0] = 0;
ts.ExeWorkDir[0] = 0;
ts.StartEverySec = 0;
ts.StartSecAfterBoot = 0;
ts.StartActivated = 1; // yes
ts.StartDeleteAfter = 0; // no
ts.StartWorkingOnly = 0; // no
ts.StartBell = 1; // yes
ts.StartNotAfter[0] = 0;
ts.WindowState = 0; // 0-5 default: 0
ts.PriorityLevel = 2; // 0-3 default: 2

GetLocalTime(&st);
st.wMinute += 5;
if(st.wMinute > 59)
{
st.wMinute -= 60;
st.wHour++; // and so on...
}
wsprintf(ts.StartNextDate, "%04i/%02i/%02i %02i:%02i:%02i", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
SetTimerSet(&ts); // save to reg
Start12timer(); // restart Timer

return;
}

// --- save timer to registry -------------------
BOOL SetTimerSet(TIMERSET *pts)
{
HKEY hkNewKey;
char szFullKeyName[MAX_PATH];
DWORD dwDummy;
DWORD dwReturn;

lstrcpy(szFullKeyName, APPREGKEY);
lstrcat(szFullKeyName, "\\");
lstrcat(szFullKeyName, pts->SubKeyName);

// Open/Create Key for write access
dwReturn = RegCreateKeyEx(HKEY_CURRENT_USER, szFullKeyName, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkNewKey, &dwDummy);
if(ERROR_SUCCESS != dwReturn)
{
SetLastError(dwReturn);
myErr("Error writing to registry! Can not open application key.");
return FALSE;
}

// Set SZs
RegSetValueEx(hkNewKey, "ExeDescription", 0, REG_SZ, (CONST BYTE *) pts->ExeDescription, lstrlen(pts->ExeDescription) + 1);
RegSetValueEx(hkNewKey, "ExePath", 0, REG_SZ, (CONST BYTE *) pts->ExePath, lstrlen(pts->ExePath) + 1);
RegSetValueEx(hkNewKey, "ExeParameters", 0, REG_SZ, (CONST BYTE *) pts->ExeParameters, lstrlen(pts->ExeParameters) + 1);
RegSetValueEx(hkNewKey, "ExeWorkDir", 0, REG_SZ, (CONST BYTE *) pts->ExeWorkDir, lstrlen(pts->ExeWorkDir) + 1);
RegSetValueEx(hkNewKey, "StartNextDate", 0, REG_SZ, (CONST BYTE *) pts->StartNextDate, lstrlen(pts->StartNextDate) + 1);
RegSetValueEx(hkNewKey, "StartNotAfter", 0, REG_SZ, (CONST BYTE *) pts->StartNotAfter, lstrlen(pts->StartNotAfter) + 1);
// Set DWORDs
RegSetValueEx(hkNewKey, "StartEverySec", 0, REG_DWORD, (CONST BYTE *) &pts->StartEverySec, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartSecAfterBoot", 0, REG_DWORD, (CONST BYTE *) &pts->StartSecAfterBoot, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartActivated", 0, REG_DWORD, (CONST BYTE *) &pts->StartActivated, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartDeleteAfter", 0, REG_DWORD, (CONST BYTE *) &pts->StartDeleteAfter, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartWorkingOnly", 0, REG_DWORD, (CONST BYTE *) &pts->StartWorkingOnly, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartBell", 0, REG_DWORD, (CONST BYTE *) &pts->StartBell, sizeof(DWORD));
RegSetValueEx(hkNewKey, "WindowState", 0, REG_DWORD, (CONST BYTE *) &pts->WindowState, sizeof(DWORD));
RegSetValueEx(hkNewKey, "PriorityLevel", 0, REG_DWORD, (CONST BYTE *) &pts->PriorityLevel, sizeof(DWORD));
RegCloseKey(hkNewKey);
return TRUE;
}


// --- Find InstallPath and start 12timer.exe -----------
void Start12timer()
{
HKEY hKey;
DWORD dwDummy = MAX_PATH;
char pszInstallPath[MAX_PATH] = {0};
char pszProgPath[MAX_PATH] = {0};
char pszTemp[MAX_PATH] = {0};
GetTempPath(MAX_PATH, pszTemp);

// get install path from Registry
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, APPREGKEY, 0, KEY_QUERY_VALUE, &hKey))
return;
if( ERROR_SUCCESS == RegQueryValueEx(hKey, "InstallPath", NULL, NULL, (LPBYTE) pszInstallPath, &dwDummy) )
{
lstrcpy(pszProgPath, pszInstallPath);
lstrcat(pszProgPath, "\\12timer.exe");
ShellExecute(NULL, NULL, pszProgPath, NULL, pszTemp, SW_SHOWNORMAL);
}

RegCloseKey(hKey);
return;
}
// --------------------------------------------

 

12Ghosts Power Tools

© 1993-2014 12Ghosts Inc. All rights reserved.