Tuesday, March 20, 2012

Controlling the Panel from Within - Part II

Last time I created a blog called 'Controlling the Panel from Within' which I posted in Weblogs. http://weblogs.foxite.com/sandstorm36/2009/05/07/controlling-the-panels-from-within/

While I showed there how we can do that, it is limited to controlling just the main applet.  It do not show how we can dig down from within that applet.  This is actually supposed to be titled 'Drilling Down an Applet' but readers may say, what the heck is that?  So I instead named this as above.

On my first blog, I showed the way to gather all applets into a form and allows user to call those applets from that listbox using ShellExecute().  Here we will use RUNDLL32 instead.  While the same can only open the main applet again, we can employ scripting here to drill down further to objects inside that applet.

Syntax is:

RUNDLL32 SHELL32.DLL,Control_RunDLL filename.CPL,@n,t

where       filename.CPL     is the name of one of Control Panel's *.CPL file,
          n           is the zero based number of the applet within the *.CPL file, and
          t           is the number of the tab for multi-paged applets

So let us say we want to open the Display applet, then you can do something like this:

Run /N rundll32.Exe shell32.dll,Control_RunDLL Desk.cpl,,2

RUN /N is of course needed to run it from within VFP.

However, again that shows only the main display applet (although now we were able to control which tab will be active when that applet is called).  This blog actually comes from one question inside foxite forum where subject seems to want to tap onto Messagebox settings of the Advanced Appearance portion (although not exactly like that).  To do that, we have to employ some minor Scripting using SendKeys:

So the command will now be like this:

Run /N rundll32.Exe shell32.dll,Control_RunDLL Desk.cpl,,2
Local loShell As wscript.Shell
loShell=Createobject("wscript.shell")
loShell.SendKeys("{TAB}{TAB}{TAB}{TAB}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}")
               



I hope you can use this trick to work directly more deeper on other control panel applets.  Enjoy!


        

No comments:

Post a Comment