Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[function] Control panel + ask for help


  • Please log in to reply
8 replies to this topic
Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Function
ControlPanel(ControlPanelItem = "") {	; by Learning one.
	if (ControlPanelItem = "") {	; than return list of control panel items
		For oCplItem In ComObjCreate("Shell.Application").Namespace(0x0003).Items
			ItemsList .= oCplItem.Name "`n"
		Sort, ItemsList
		return RTrim(ItemsList, "`n")
	}
	else {	; run specified control panel item
		For oCplItem In ComObjCreate("Shell.Application").Namespace(0x0003).Items {	
			If (oCplItem.Name = ControlPanelItem) {
				oCplItem.Verbs.Item(0).DoIt
				return 1
			}
		}
	}
}
Examples
MsgBox % ControlPanel()	; shows list of control panel items
ControlPanel("System")		; runs specified control panel item


sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
<!-- m -->http://img34.imagesh.../img0001utt.jpg<!-- m -->

What control panel do you refer to? It's not the standard Windows one.

Thanks for sharing anyway :p

By the way, control panel spells PANEL with one n, not pannel

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
I'm refering to standard Windows control panel. I'm on Win XP and it works as described. Here is what I get when I run MsgBox % ControlPanel()
What's your OS?

btw, typo fixed :p

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

I'm refering to standard Windows control panel. I'm on Win XP and it works as described. Here is what I get when I run MsgBox % ControlPanel()
What's your OS?

btw, typo fixed :p


Tried again, got the same list of programs. I'll try it on my laptop later. I'm running Windows 7 x64 bit on my desktop and 32 bit on my laptop.

Edit: It gives a full list of items on my laptop.

I'm imagining this could be useful to give a direct link to specific Control Panel items (if) they exist.

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Can you please edit your first post to tell everyone this is for AHK_L? :)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006

Function

Nice!

Can you please edit your first post to tell everyone this is for AHK_L? :)

Now i think, only those using basic should label their posts :p :). *Just joking*
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I get the full list of Control Panel items when running the script as 64-bit, including some third-party items, and nothing at all when running the script as 32-bit. I suppose I don't have any 32-bit Control Panel items.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
sumon's case:
works on Windows 7 x32
does not work as expected on Windows 7 x64 - returns incomplete list of items

Lexikos' case:
works when running the script as 64-bit
does not work at all when running the script as 32-bit

my case:
works on WinXP sp3 32 bit

another tested case:
works on Win Vista 32 bit

:? :?: What's wrong with the function? How to write it to work in all cases?



* * *

Can you please edit your first post to tell everyone this is for AHK_L? :)

Now i think, only those using basic should label their posts :p :). *Just joking*

+ 1 for shajul, but I'm not joking. AHK_L unicode build is a mainstream now.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Bump - for ask for help part - see post above