nielsie95
2008-09-24 12:51:14
Hey,
The wallpaper changer by hermpie made me want to try something alike in SCAR. So here it is, I can not ensure it works for you, but for me it does (Windows XP).
Make sure you enable API-calls, allow access to WallPaper.reg and make sure the directory you enter ends with a \.
The wallpaper changer by hermpie made me want to try something alike in SCAR. So here it is, I can not ensure it works for you, but for me it does (Windows XP).
Make sure you enable API-calls, allow access to WallPaper.reg and make sure the directory you enter ends with a \.
program WallpaperChanger;
const
SwitchTime = 1; //in minutes
Directory = 'C:\';
function UpdatePerUserSystemParameters(const wStyle: LongInt; const bWaitOnReturn: LongBool): LongBool; external 'UpdatePerUserSystemParameters@user32.dll stdcall';
function ShellExecute(hWnd: HWND; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer): LongInt; external 'ShellExecuteA@shell32.dll stdcall';
var
f, Current: Integer;
Files: TStringArray;
Dir: string;
begin
Files := GetFiles(Directory, 'bmp');
if (Length(Files) < 1) then
begin
WriteLn('No bitmaps in directory');
TerminateScript;
end;
Dir := Replace(Directory, '/', '\');
Dir := Replace(Directory, '\', '\\');
Current := 0;
MoveToTray;
repeat
if (not FileExists(Directory + Files[Current])) then
begin
WriteLn('File doesn''t exist: '+Files[Current]);
Break;
end;
Writeln('Switching to '+Files[Current]);
f := RewriteFile(AppPath + 'WallPaper.reg', False);
WriteFileString(f, 'Windows Registry Editor Version 5.00'#13#10#13#10+
'[HKEY_CURRENT_USER\Control Panel\Desktop]'#13#10+
'"Wallpaper"="'+Dir+Files[Current]+'"');
CloseFile(f);
ShellExecute(GetApplication.Handle, 'open', 'regedit.exe', '/s WallPaper.reg', AppPath, 1);
Status('Timing out to ensure the registery file is processed');
Sleep(10 * 1000);
Status('Refreshing screen');
UpdatePerUserSystemParameters(1, True);
Current := (Current + 1) mod Length(Files);
Status('Waiting '+IntToStr(SwitchTime)+' minutes');
Sleep(SwitchTime * 1000 * 60);
until False;
end.