Active Desktop Small yet Powerful Function

S

SuperSheep

Guest
#1
Didn't know if I should post this here or in the Active Desktop Tutorial thread but as that thread is getting mighty long, I thought this would stand a better chance of getting seen here.

I've been digging into different ways of accessing various things like Control Panel items, Drives, and such and have finally found a miraculous new way, Namespaces. Try this code out for yourself and you be the judge...

Code:
<HTML><HEAD><TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript">
// System Constants
var ssfDESKTOP          = 0;    // Windows Desktop
var ssfPROGRAMS         = 0x2;  // User's program groups
var ssfCONTROLS         = 0x3;  // Icons for the Control Panel applications
var ssfPRINTERS         = 0x4;  // Installed printers
var ssfPERSONAL         = 0x5;  // User's documents
var ssfFAVORITES        = 0x6;  // User's favorite items
var ssfSTARTUP          = 0x7;  // User's Startup program group
var ssfRECENT           = 0x8;  // User's most recently used documents
var ssfSENDTO           = 0x9;  // Send To menu items
var ssfBITBUCKET        = 0xa;  // Recycle Bin
var ssfSTARTMENU        = 0xb;  // Directory containing Start menu items
var ssfDESKTOPDIRECTORY = 0x10; // File objects that are displayed on the desktop
var ssfDRIVES           = 0x11; // My Computer
var ssfNETWORK          = 0x12; // Network Neighborhood
var ssfNETHOOD          = 0x13; // Link objects that may exist in the My Network Places 
var ssfFONTS            = 0x14; // Installed fonts
var ssfTEMPLATES        = 0x15; // Document templates
var ssfCOMMONSTARTMENU  = 0x16; // Programs and folders that appear on Start menu for all users
var ssfCOMMONPROGRAMS   = 0x17; // Directories for common program groups that appear on Start menu for all users
var ssfCOMMONSTARTUP    = 0x18; // Programs that appear in the Startup folder for all users
var ssfCOMMONDESKTOPDIR = 0x19; // Files and folders that appear on the desktop for all users
var ssfAPPDATA          = 0x1a; // Application-specific data
var ssfPRINTHOOD        = 0x1b; // Link objects that may exist in the Printers virtual folder
var ssfLOCALAPPDATA     = 0x1c; // Local (non-roaming) applications
var ssfALTSTARTUP       = 0x1d; // User's nonlocalized Startup program group
var ssfCOMMONALTSTARTUP = 0x1e; // Nonlocalized Startup program group for all users
var ssfCOMMONFAVORITES  = 0x1f; // All users' favorite items
var ssfINTERNETCACHE    = 0x20; // Temporary Internet files
var ssfCOOKIES          = 0x21; // Internet cookies
var ssfHISTORY          = 0x22; // Internet history items
var ssfCOMMONAPPDATA    = 0x23; // Application data for all users
var ssfWINDOWS          = 0x24; // Windows directory or SYSROOT
var ssfSYSTEM           = 0x25; // System folder
var ssfPROGRAMFILES     = 0x26; // Program Files folder
var ssfMYPICTURES       = 0x27; // My Pictures folder
var ssfPROFILE          = 0x28; // User's profile folder

// Variables
var sa  = new ActiveXObject("Shell.Application");
var ssf = new Array(0x28);

function PopulateAll() {
	Populate(ssfCONTROLS, 'ocpanel');
	Populate(ssfDRIVES, 'odrives');
	Populate(ssfFONTS, 'ofonts');
	Populate(ssfMYPICTURES, 'omypictures');
}

function Populate(ssfItem,cID) {
	ssf[ssfItem] = new Object(sa.NameSpace(ssfItem));
	var ssfItems = new Object(ssf[ssfItem].Items());
	eval("document.all."+cID+".Name=ssfItem");
	for(i=0; i<ssfItems.Count; i++) {
		var oOption  = document.createElement("OPTION");
		oOption.text = ssfItems.Item(i).Name;
		eval("document.all."+cID+".add(oOption)");
	}
}
function RunSpecial(ssfItem, index) {
	var ssfItems = new Object(ssf[ssfItem].Items());
	ssfItems.Item(index).InvokeVerb();
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="PopulateAll()">
<FORM>
<SELECT ID="ocpanel" SIZE="10"
 ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="odrives" SIZE="10"
 ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="ofonts" SIZE="10"
 ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="omypictures" SIZE="10"
 ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
</FORM>
</BODY></HTML>
Just copy & paste into notepad and save as test.html or whatever you prefer and see the power of Namespaces. I decided to write a single function to populate the listboxes as well as run the items to make it even more efficient.

Questions & Comments are welcome. :D
 
S

slayer[X]

Guest
#3
How can i delete the fonts menu and replace it with my documents folder menu?

*EDIT* Nevermind. Got it.
Good job.:D
 
J

Jason Roberts

Guest
#4
Very Cool! I will be using the My Computer and the Control Panel and the My Documents list. How do I delete the fonts list?
:D :D ;)
 
S

SuperSheep

Guest
#6
Jason-

No problem. Just remove the highlighted lines-

In the Javascript function-

function PopulateAll() {
Populate(ssfCONTROLS, 'ocpanel');
Populate(ssfDRIVES, 'odrives');
Populate(ssfFONTS, 'ofonts');
Populate(ssfMYPICTURES, 'omypictures');
}

And in the HTML-

<FORM>
<SELECT ID="ocpanel" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="odrives" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="ofonts" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>

<SELECT ID="omypictures" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
</FORM>

You may also add items by simply following the format shown. In SELECT ID, you would name it something obvious, like ofonts although the name does not matter as long as it is unique.
Then in the PopulateALL function, add a line just like the rest that specifies the constant from the list of constants and the name that you specified.

You can also use these functions if modified to support any desired display method such as menus, treeviews(good for stuff like Favorites) and any other display method you choose. You would need to alter the Populate function for your particular method and there are plenty of great tutorials out there that demonstrate menus and interaction with JavaScipt, what is commonly referred to as DHTML.

Also...Thanks for all the great comments. It took me a while to come up with a method of doing this and I'm glad people can find a use for it.
 
J

Jason Roberts

Guest
#7
SuperSheep...thank you very much for your information. I've customzised and added a few more lists. Successful! Thanks. Might add it to my active desktop or add a link to it. I will look into it and then show you all a snapshot of my active desktop later in the March Capture thread. :D ;)
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,975
Messages
673,316
Members
89,017
Latest member
Rowdanger