Active Desktop Tutorial

Here is another cool little JavaScript. This one checks for the status of the recycle bin...

// Determines if recycle bin has contents
function chkrecycle()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder("C:\\RECYCLER\\S-1-5-21-1214440339-926492609-839522115-1003");
fc = new Enumerator(f.Files);
for(s=-2;!fc.atEnd(); fc.moveNext()) {s++;}
fs = new Enumerator(f.SubFolders);
for(;!fs.atEnd(); fs.moveNext()) {s++;}
if(s>0) return true;
else return false;
}

The number after the C:\\RECYCLER\\ is my ID. Yours will be different. Check it by enabling 'Show Hidden files' and unchecking 'Hide protected operating system file', then navigate to your RECYCLER folder and copy that ID. You should also check to see what YOUR default number of files and folders is. I have 2 drives, so I have 2 files within the directory for each drive. substitute the 2 with your own number of files.
 
Supersheep...!
That was my idea!
I've got a better universal code...
But I can't integrate it in html for now...

It seems that you are experienced with JS
So could you help me ?

I'll send you PM
 
I got it to work:

I've got a code to check if Trash is Empty...You don't need to know any ID for that...
You can show a specified image or a text for the states...
Also, it's possible to display number of files in Trash...

Will be available in some hours at my HP (see Sig)

@Supersheep: No help needet...Thanks anyway... :)
 
Heh, sorry about that. I looked all over the internet for a script to check the recycle bin contents but couldn't find one. I took a look at the code you sent me by PM and it seems your code is a lot more *ahem* efficient and easy to read. :D

I guess that just proves the old saying, 'more than one way to skin a cat'
 
OK Guys...

Just uploaded my trash script to my Homepage (see sig)
Can be found in Download Section...

Hope you like it
 
hi angel, thx for the script... i encountered a small problem with gordian knot... wasnt able to use to programs within gordian knot, since the working directory wasnt passed over with the shellexecute... so i changed it with another argument:
<script language="JScript">
function ShellExJ(filename,arg,arg2,count)
{
var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute(filename, arg, arg2, "open", count);
}
</script>

the arg2 can be set to the working directory...

<a target="_self" href="javascript:ShellExJ('C:\\Program

Files\\GordianKnot\\GordianKnot.exe','','C:\\Program Files\\GordianKnot');"><b>gordian knot</

b></a>
 
is there anyway to round the freediskspace with a function? i like to have a MB parameter there... allready devided the value by 1024/1024, but it has too many decimals, so i wonder how to format it like to something like this: 1.200 MB



Originally posted by SuperSheep
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.
 
not sure about Java but there should be an "int" function or something that only takes the integer value and leaves the decimals.
 
Some ppl didn't get to run some tools with the shellexj method
like gordian knot...

I figured it out and I'll add it to my HP in about 2 days...

also the question about rounding the values will be explained...
Together with some more explantation to WMI possibilities...

So check it out (See Sig)
 
Originally posted by dworn
is there anyway to round the freediskspace with a function? i like to have a MB parameter there... allready devided the value by 1024/1024, but it has too many decimals, so i wonder how to format it like to something like this: 1.200 MB

Yes, I was thinking the same thing when I wrote the functions but hadn't implemented it.

Here is one way:

Change the displayInfo function with this...

INFO4.innerText="Free Disk Space: "+getformatted(objinst.FreeSpace/1048576)+"MB";

Change the getformatted function to...

function getformatted(inputval)
{
// Set wholePart equal to the whole portion of the value
wholePart = Math.floor(inputval);
// Set decimalPart equal to the decimal portion of the value
decimalPart = inputval-wholePart;
// Set lineLength equal to the number of characters in wholePart
lineLength = wholePart.length;

if(lineLength>9) returnval=wholePart.substr(0,lineLength-9)+","+wholePart.substr(lineLength-9,3)+","+wholePart.substr(lineLength-6,3)+","+wholePart.substr(lineLength-3,3);
else if(lineLength>6) returnval=wholePart.substr(0,lineLength-6)+","+wholePart.substr(lineLength-6,3)+","+wholePart.substr(lineLength-3,3);
else if(lineLength>3) returnval=wholePart.substr(0,lineLength-3)+","+wholePart.substr(lineLength-3,3);
else returnval=wholePart;

// Add 3 decimal digits + the decimal to the value returned
returnval+=decimalPart.substr(0,4);
return returnval;
}

If you want KB, divide the value by 1024 before passing it, in MB, then divide the value by 1024^2 or 1048576, and GB, divide by 1024^3 or 1073741824.

Enjoy. :)
 
I am workin on a Active Desktop which is going great. I only have two problems.
  1. I can't launch programs from links
  2. I can't get the notepad to work
    [/list=1]


    My code can be found at: www.spingk.us/AD.txt

    I've included a picture of it so far.

    *If anyone has suggestions for stuff to add BESIDES CPU info than please post it*
 


// Add 3 decimal digits + the decimal to the value returned
returnval+=decimalPart.substr(0,4);
return returnval;
}

If you want KB, divide the value by 1024 before passing it, in MB, then divide the value by 1024^2 or 1048576, and GB, divide by 1024^3 or 1073741824.

Enjoy. :) [/B]


doesnt work in the line with returnval... ie gives me a script error,
that the object doesnt support this method....
 
Sorry bout that, I didn't test the function, but here ya go, this one has been tested...

function getformatted(inputval) {
// Set wholePart equal to the whole portion of the value
wholePart = Math.floor(inputval).toString();
// Set decimalPart equal to the decimal portion of the value
decimalPart = inputval-wholePart;
// Set lineLength equal to the number of characters in wholePart
lineLength = wholePart.length;

if(lineLength>9) returnval=wholePart.substr(0,lineLength-9)+","+wholePart.substr(lineLength-9,3)+","+wholePart.substr(lineLength-6,3)+","+wholePart.substr(lineLength-3,3);
else if(lineLength>6) returnval=wholePart.substr(0,lineLength-6)+","+wholePart.substr(lineLength-6,3)+","+wholePart.substr(lineLength-3,3);
else if(lineLength>3) returnval=wholePart.substr(0,lineLength-3)+","+wholePart.substr(lineLength-3,3);
else returnval=wholePart;

// Add 3 decimal digits + the decimal to the value returned
returnval+=decimalPart.toString().substr(1,4);
return returnval;
}
 
I think the function you need to get rid of the decimals is "intval" but I am not 100% sure
 
Originally posted by dworn
Free Disk Space: 1,717.851MB

this is what i get

And I'm guessing that's not what you wanted, eh? I'm figuring that would be for a couple reasons...

1) It's still too long. You could remove the decimal stuff by simply removing the returnval+=decimalPart...

2) You actually wanted it in GB. Just divide by 1024^3 instead of 1024^2 before passing it to getformatted.

3) Commas are decimals in your country? Replace instances of "," with "."

Other than that, it looks correct to me? :huh:
 
1) i try
2) mb might be better
3) yes, i will try....(i live in germany)

4) thnx a lot...

5) wishlist: can u also show the networktraffic?



Originally posted by SuperSheep
And I'm guessing that's not what you wanted, eh? I'm figuring that would be for a couple reasons...

1) It's still too long. You could remove the decimal stuff by simply removing the returnval+=decimalPart...

2) You actually wanted it in GB. Just divide by 1024^3 instead of 1024^2 before passing it to getformatted.

3) Commas are decimals in your country? Replace instances of "," with "."

Other than that, it looks correct to me? :huh:
 
Ahh, I figured that's what it was. I've dealt with one other person from overseas over this exact same issue involving another program I wrote some time ago.

Definately, just remove the returnval+=decimalPart... stuff
and replace the "," in the getformatted function to "." and you should be good to go. :)

Network Traffic eh? :eek:

Someone with a lot more skills at sifting through the WMI specs than me will have to do that one. I was able to throw that code together and I don't think it's probably very good but it was the best I could come up with and I'm glad someone can find a use for it but...
I tried just playing around with the Network adapter and POTS modem commands and wasn't able to get more than a Name, Model # and status, unfortunately no traffic.

Check the Coolmon if you want to implement a lot of different tracking of system specs. They made an ActiveX component that does a whole lot more than my code for monitoring and is free. My only reasoning behind making this code was to see if it could be done in JavaScript and while it can, these guys know a lot more than I about this stuff.
 
thats fine.. i don't want to use any other programs, i want to make everything via script and html... i realy think that madmatt has showed us the power of active desktop, and its a shame for microsoft, that the used their own feature like nothing.. just have a look at the gallery of microsoft for their active desktop "plugins"... nothing usefull there... this active desktop realy shows the power a user can get to make his system to like the way one wants... i dont use the startmenu anymore, its all done via active desktop... so big up to madmatt, angel and all the other people that shifted the active desktop to the next dimension....
 
Thanks to dword...

And btw: Just updated my HP with some new scripts in dl section and improvements in the Howto

And lieb39...if you read that plz mail back...You told me sth.
But now I can do what I want...no answer...
 

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