Active Desktop Tutorial

I am trying to come up with a way to change the background my active desktop when I click a button. There are two ways that I am thinking about doing this:

- Javascript: Having a variable for the wallpaper (maybe having the wallpapers named 1.jpg, 2.jpg, 3.jpg...) which is then incremented when the button is pressed. This then changes the wallpaper background in the body tag and the page is refreshed.

- CSS having maybe half a dozen wallpapers at one time loaded (this shouldn't be too intensive) and then using the layer type function in css to move the specific wallpaper that is needed to the top (possibly in conjuction with Javascript).

Any ideas how to actually implement one of these ideas?
 
Do you want to change your desktop wallpaper or do you just want to change the background image of your html file ?

HTML file should be easy...

But desktop...
 
Just the image (html). There is a way to change the actual desktop image but this isn't applicable as the active desktop covers the whole desktop.
 
ToDo v.4 out

Here's the final (v4) version of Todo. Its a script that shows a todo list that can be placed on active desktop. Created by Zedric and edited by lieb39.

This is the NTFS version.

Let me know what you think of it.
 
Hey. It has been a while since I last visited this Thread. This thread was only 22 pages long. but now its around 45! :eek:

Ok anyway. I have a question. I have refubished my active desktop. I am going to use images for the programs. When I click a picture, that should launch a program. How do I place the Href code within the image?

And how do you do the sliding menus. I know the answer would be somewhere herebut I am short of time.

thanks to those who would answer.
 
Re: ToDo v.4 out

Originally posted by lieb39
Here's the final (v4) version of Todo. Its a script that shows a todo list that can be placed on active desktop. Created by Zedric and edited by lieb39.

Awesome submission, thanks a lot! The only thing I'm not too keen on is including the username/password. I don't run php locally and I can block access to the remote file, but there's something about having my login info sitting on the server I just don't quite feel right about. :)

My paranoia aside, great work and it works great!
 
Originally posted by Jason Roberts
When I click a picture, that should launch a program. How do I place the Href code within the image?


Ya mean something like this?
<a href="program-path"><img src="image.gif" border="0"></a>


Here's a line of code from my dtop, but using the exec function:

<a target="_self" onClick=" ShellExJ('C:\\Program Files\\WS_FTP Pro\\wsftppro.exe')" href="javascript:;"><img src="gfx/ftp_ico.gif"border="0"></a>
 
Can someone give me a hand with creating a dhtml menu, using the ShellExJ launch method? I created the menu script but can't figure out the code. The vbs method works, of course.

Thanks.

Updated dtop here
 
How do you setup program shortcuts without placing them in the Windows folder? I want to keep my active desktop files inside one folder and be able to move it and still work.
Example:
Main Folder: desktop - will hold all html/htm, js, css files
Subfolder: shortcuts - will hold all shortcut and vbs files
Subfolder: images - will hold any image files

Coding for html file for program:
<HTML>
<HEAD>
<script>
function exec (command) {
if (document.layers && navigator.javaEnabled()) {
window._command = command;
window.oldOnError = window.onerror;
window.onerror = function (err) {
if (err.indexOf ("User didn't grant") != -1) {
alert('command execution of ' + window._command +
' disallowed by user.');
return true;
}
else return false;
}
netscape.security.PrivilegeManager.enablePrivilege
('UniversalExecAccess');
java.lang.Runtime.getRuntime().exec(command);
window.onerror = window.oldOnError;
}
else if (document.all) {
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('command execution of ' + window._command +
' disallowed by user.');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
}
</script>
</HEAD>
<BODY>
<a onClick="exec('restore.vbs'); return false;" href="java script:void(0)">RestoreIt!</a>
</BODY>
</HTML>

When I run the vbs file, the program runs. When I click on the link in the hmtl file, I get a warning about the scripting. I allow it to run and the program doesn't open up. Any ideas?
 
To put the shortcuts in a folder other than windows:
Control Panel > Sytem > Advanced > Environment Variables > System Variables > Path > Edit > Variable Value.
Add a ";" after the last entry and then ( without putting a space after ";" ) add your folded in there.
 
I added "D:\Custom XP\Active Desktop" since that is where I want to store everything. I have the shortcuts placed within the "Active Desktop" folder and still no improvement. :confused:
 
@Ziptrx:


Visit my Site! That'll answer the first question:
How do you setup program shortcuts without placing them in the Windows folder? I want to keep my active desktop files inside one folder and be able to move it and still work.

And perhabs the second if you use the other method.

Just click on Howto to see how it works...
 
First off, I want to say that is one awesome tutorial. I had been contemplating doing a Active Desktop for some time but the tutorial actually gave me what I needed to get off my lazy butt and do it. :)

On to the good stuff...

I've figured out a way to display the Free memory and just about anything else you want directly through using JavaScript but there is a problem, it uses some decent CPU usage to do it.

On my P4 2.53, just to update the Free Physical Memory twice per second consumed 4% CPU usage. However, some of you may find it useful and possibly if used in conjunction with a button for refresh or setting the refresh down to several seconds, it may be acceptable.

Code:
  var objinst = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select FreePhysicalMemory from Win32_OperatingSystem");
  for(e = new Enumerator(objinst) ; !e.atEnd() ; e.moveNext())
  {
    Profile=e.item();
    INFO1.innerText=Profile.FreePhysicalMemory;
  }

Then on your HTML page, you would have something such as...

Code:
<DIV ID="INFO1" STYLE="position: absolute"></DIV>

This works with a variety of messages that are exposed through the WMI which needs to be turned on as well.

From the MSDN collection, it says that '{impersonationLevl=impersonate}' is not required as it is the default. The ExecQuery command can be replaced with InstancesOf however the ExecQuery command allows one to filter the results from the call.

Also, using enumeration is necessary and does not actually cause the performance hit. The call to WMI causes that. There are some cases where you don't have to enumerate as in...

Code:
var disk = GetObject ("winmgmts:Win32_LogicalDisk='C:'")

but those seem to be rare and unneccesary as enumeration isn't to blame for the high CPU hit.

And, you do need to make the call each time you wish to check for something. I tried running it once on load and simply enumerating afterwards but that gave me the same value each time.

Also, Thanks to NTFS.org, I've got a new desktop... :D
 
I decided that my last post may have made what I was saying sound like it was impractical so I implemented a means of doing it that only impacts your CPU when you have your mouse over the desktop, i.e., when you are running other applications or your mouse is in another window, your CPU usage will drop to 0.

This method uses a different means of accessing the WMI which gives a little bit of a performance increase.

In your Body tag of your HTML document, insert this...
Code:
<BODY onmouseover="updateinfo()" onmouseout="stopupdateinfo()">

Then, somewhere within your page itself, insert this...
Code:
<DIV CLASS="SYSINFO" ID="INFO1" STYLE="position: absolute; left: 30px; top: 20px;"></DIV>
<DIV CLASS="SYSINFO" ID="INFO2" STYLE="position: absolute; left: 30px; top: 32px;"></DIV>
<DIV CLASS="SYSINFO" ID="INFO4" STYLE="position: absolute; left: 30px; top: 56px;"></DIV>
<DIV CLASS="SYSINFO" ID="INFO3" STYLE="position: absolute; left: 30px; top: 44px;"></DIV>

You may wish to alter the position information and change font styles, that is fine.

Then, create a Javascript either in a separate file or within your HEAD of your HTML page and insert the following...

Code:
var locator = new ActiveXObject("WbemScripting.SWbemLocator"); // Get locator object
var service = locator.ConnectServer();
var infoID = null;
function updateinfo() {
	if(infoID !=null) clearInterval(infoID);
	window.setTimeout("displayInfo()",10); infoID=window.setInterval("displayInfo()",1000);
}

function displayInfo() {
	var objinst = service.InstancesOf("Win32_OperatingSystem");
	for(e = new Enumerator(objinst) ; !e.atEnd() ; e.moveNext())
	{
		Profile=e.item();
		INFO1.innerText="Free Physical Memory: "+getformatted(Profile.FreePhysicalMemory)+"KB";
		INFO2.innerText="Free Virtual Memory: "+getformatted(Profile.FreeVirtualMemory)+"KB";
		INFO3.innerText="Number of Processes: "+Profile.NumberOfProcesses;
	}
	var objinst = service.Get("Win32_LogicalDisk=\"C:\"");
	INFO4.innerText="Free Disk Space: "+getformatted(objinst.FreeSpace)+"B";
}

function stopupdateinfo() {
	window.clearInterval(infoID);
	infoID=null;
}
function getformatted(inputval)
{
	linputval=inputval.length;
	if(linputval>9)      returnval=inputval.substr(0,linputval-9)+","+inputval.substr(linputval-9,3)+
","+inputval.substr(linputval-6,3)+","+inputval.substr(linputval-3,3);
	else if(linputval>6) returnval=inputval.substr(0,linputval-6)+","+inputval.substr(linputval-6,3)+
","+inputval.substr(linputval-3,3);
	else if(linputval>3) returnval=inputval.substr(0,linputval-3)+","+inputval.substr(linputval-3,3);
	else                 returnval=inputval;
	return returnval;
}

This will display the Free Physical Memory, Free Virtual Memory, Free hard drive space, and Number of processes. The list of things you can add is limited only by what WMI can provide. This method of scripting works great because it only consumes CPU usage while the mouse is over the desktop itself and otherwise it sleeps.

I'd be interested to here if anyone else has tried this and how it worked for them and if this is even a good idea.

Here's a shot of my desktop running. My mouse is over the desktop and you can see the CPU utilization.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,495
Members
5,624
Latest member
junebutlertd
Back