SRL Archive - Research & Development Lounge

Wallpaper Changer


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 \.


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.

ShowerThoughts

2008-09-24 12:53:57

I prefer using a .exe because it's faster, and it has it own icon.
also it does not works for me I enabled api calls.

Wizzup?

2008-09-24 12:57:51

From: Hermpie
I prefer using a .exe because it's faster, and it has it own icon.
also it does not works for me I enabled api calls.


A .exe doesn't show the source, though.
Also, I think API calls from SCAR are as fast as from .exe's. ;)

ShowerThoughts

2008-09-24 13:00:43

From: Wizzup?
A .exe doesn't show the source, though.
Also, I think API calls from SCAR are as fast as from .exe's. ;)


I maybe didn't say it right I mean you have to open scar and then put it in there + it had the regular scar icon + a .exe auto enables api calls can be good or bad , depends.

For the newbs a .exe is easier ^^

nielsie95

2008-09-24 13:13:04

From: Hermpie
I prefer using a .exe because it's faster, and it has it own icon.
also it does not works for me I enabled api calls.


Are you on Vista?
Did you enter a correct folder (ending on a \)?
Did you wait 15 seconds after starting?

mastaraymond

2008-09-24 14:22:50

Win ^_^.

ShowerThoughts

2008-09-24 15:39:07

From: nielsie95
Are you on Vista?
Did you enter a correct folder (ending on a \)?
Did you wait 15 seconds after starting?


No,
I thought C\ would check all folders(also sub) inside :p mine wallpaper changer does.
Yes.