關於 WIN Vista & WIn7 資訊看版
經查了一下 原來在 C:\Users\EBM\appdata\local\microsoft\windows sidebar\gadgets 和 C:\Program Files\Windows Sidebar\Gadgets
分別為相關的資料夾 在看一下說明
建立時共需要資訊清單(XML) 及一個 html 並放入至一個已.Gadget為資料夾內 如
而XML的內容則依M$的提示
<?xml version="1.0" encoding="utf-8" ?> <gadget> <name>My First Gadget</name> <author>The Microsoft Scripting Guys</author> <copyright>2006 Microsoft Corporation</copyright> <description>Sample gadget that returns the name of the installed operating system.</description> <icons> <icon>icon.png</icon> </icons> <version value="1.0.0.0" MinPlatformVersion="0.1"></version> <sidebar> <type>html</type> <permissions>full</permissions> <code>test.htm</code> <website>www.microsoft.com/technet/scriptcenter</website> </sidebar> </gadget>
你不用問,是的,你可以直接複製這個檔案,就這樣幾乎原封不動地使用,只要稍稍 (視需要) 改變一些標記值就行了 (還有,別忘了!必須將檔案命名為 Gadget.xml)。你可能要或必須要修改的標記就在下表中指定:
標記 |
說明 |
<name> |
顯示在小工具選擇器對話方塊中的小工具名稱。 |
<author> |
小工具作者的姓名。按一下特定小工具時,作者、著作權和說明標記都會顯示在小工具選擇器中。如需詳細資訊,請參閱下面顯示的圖例說明。 |
<copyright> |
著作權資訊,包括著作權所有人姓名和著作權日期。 |
<description> |
小工具的簡要說明及其作用。 |
<icon> |
圖示檔案的名稱 (圖示是顯示在小工具選擇器中的圖形)。如需有關圖示的詳細資訊,請參閱本文件下列小節中的<建立圖示>。 |
<code> |
大概不是很直覺式的標記名稱,但這是組成你的小工具的 HTML 檔名稱。 |
<website> |
與小工具相關聯的網站。 |
為了更清楚、更簡潔地說明這些標記,下面就把資訊清單元素逐一對應到小工具選擇器對話方塊中所顯示的項目:
應該很清楚啦
而將WMI等小程式加入html中 則完成你個人的小工具
而基於安全性的考量,網頁中不能使用 GetObject 和 winmgmts:moniker。你必須改用 CreateObject 來建立 WbemScripting.SWbemLocator 物件的執行個體,再用 ConnectServer 方法,連線到 WMI 服務
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
需改為
Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")
不然你會收到
ActiveX component can't create object: 'GetObject'
已下提供一個範例
<html> <head> <title>My First Gadget</title> <style> body{width:120;height:160} </style>
</head> <script language="VBScript"> Sub RunSub strComputer = "." Set objLocator = CreateObject("WbemScripting.SwbemLocator") Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem") For Each objItem in colItemsDataArea.InnerHTML = objItem.Caption Next End Sub </script> <body> <input type="button" value="Run" name="run_button" onClick="RunSub">Msgbox objItem.Caption
<span id="DataArea"></span>
</body> </html>
若要將彈跳視窗改為直接顯示於小工具上則可改寫(刪除紅線部份加入紅字部份)
說了本天 下去測的結果 失敗= ="""" 原來上述的gadget.xml僅適用於Vista 而Win7則有變更
<?xml version="1.0" encoding="utf-8" ?> <gadget> <name>My First Gadget</name>
<namespace><!--_locComment_text="{Locked}"-->Yourname.Test</namespace><!--小工具命名空間-->
<version><!--_locComment_text="{Locked}"-->1.0.0.0</version><!--小工具版本號-->
<info url="http://panel.pixnet.cc" text="痞客邦"/><!--更多信息,鏈接和顯示內容-->
<logo src="logo.png"/><!--小工具的LOGO-->
<author>The Microsoft Scripting Guys</author> <copyright>2006 Microsoft Corporation</copyright> <description>Sample gadget that returns the name of the installed operating system.</description> <icons> <icon>icon.png</icon> </icons> <hosts>
<host name="sidebar">
<autoscaleDPI><!--_locComment_text="{Locked}"-->true</autoscaleDPI><!--是否自適應分辨率-->
<base type="HTML" apiVersion="1.0.0" src="Test.html"/><!--小工具主體HTML文件-->
<permissions><!--_locComment_text="{Locked}"-->Full</permissions>
<platform minPlatformVersion="1.0"/><!--小工具能正常運行的最低平台-->
<defaultImage src="drag.png"/><!--當小工具被拖動時,顯示的圖形-->
</host>
</host>
</gadget>
留言列表