Add the console to the Vista sidebar

This commit is contained in:
Lucidiot 2024-05-04 03:32:37 +02:00
parent 21f28fa0d7
commit 731d89d727
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
12 changed files with 87 additions and 1 deletions

1
Console.Gadget/console.css Symbolic link
View File

@ -0,0 +1 @@
../console.css

1
Console.Gadget/console.html Symbolic link
View File

@ -0,0 +1 @@
../console.html

1
Console.Gadget/console.js Symbolic link
View File

@ -0,0 +1 @@
../console.js

1
Console.Gadget/console.vbs Symbolic link
View File

@ -0,0 +1 @@
../console.vbs

24
Console.Gadget/gadget.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<gadget>
<name>Windows Scripting Console</name>
<namespace><!--_locComment_text="{Locked}"-->lucidiot</namespace>
<version><!--_locComment_text="{Locked}"-->1.0</version>
<author name="~lucidiot">
<info url="https://tildegit.org/lucidiot/xp-consoles/" text="tildegit.org/lucidiot/xp-consoles"/>
<logo src="logo.png"/>
</author>
<copyright><!--_locComment_text="{Locked}"-->GNU GPL 3</copyright>
<description>Run JavaScript and VBScript from within a gadget.</description>
<icons>
<icon height="48" width="48" src="icon.png"/>
</icons>
<hosts>
<host name="sidebar">
<autoscaleDPI><!--_locComment_text="{Locked}"-->true</autoscaleDPI>
<base type="html" apiVersion="1.0.0" src="console.html"/>
<permissions><!--_locComment_text="{Locked}"-->full</permissions>
<platform minPlatformVersion="1.0"/>
<defaultImage src="icon.png"/>
</host>
</hosts>
</gadget>

BIN
Console.Gadget/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
Console.Gadget/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -12,3 +12,4 @@ I will try to document how I placed the consoles in each spot, how you can do it
* Microsoft Management Console (soon™)
* System Restore (soon™)
* Help and Support Center (soon™)
* [Windows Vista Sidebar](docs/gadget.md)

View File

@ -1,4 +1,4 @@
function JSEval (code) {
function JSEval (code) {
try {
return eval(code);
} catch (err) {
@ -15,6 +15,10 @@ function hasWebWizardExtensions () {
return supportsVB() ? InWebWizard() : typeof window.external.SetWizardButtons === 'unknown'
}
function hasGadgetExtensions () {
return supportsVB() ? InGadget() : (typeof window.System === 'object' && typeof window.System.Gadget == 'object')
}
function inSketchUp () {
return /\bSketchUp\//.test(navigator.userAgent)
}
@ -231,3 +235,10 @@ try {
originalConsole.error('Could not setup Web Wizard extensions:', err)
}
}
// Install the dock/undock event when running the console as a Windows Vista/7 Sidebar gadget.
if (hasGadgetExtensions()) {
System.Gadget.onDock = System.Gadget.onUndock = function () {
document.body.style.width = document.body.style.height = System.Gadget.docked ? 130 : 300;
}
}

View File

@ -20,4 +20,9 @@ End Function
'Auto-detect the wizard's browser extensions
Function InWebWizard()
InWebWizard = TypeName(window.external) = "INewWDEvents"
End Function
'Auto-detect the Windows Vista/7 sidebar gadget extensions
Function InGadget()
InGadget = TypeName(window.System) = "DispSystem" And TypeName(window.System.Gadget) = "DispGadget"
End Function

41
docs/gadget.md Normal file
View File

@ -0,0 +1,41 @@
# Windows Sidebar gadget
Windows Vista introduced the [Windows Sidebar][sidebar-docs], on which *gadgets* may be placed. Windows 7 removed the sidebar but kept the gadgets, and Windows 8 removed the gadgets.
Gadgets are nothing more than a webpage shown in a strange way, similar to Active Desktop. They get access to some extra features:
* An ActiveX object on the `window.System` global variable, giving access to many methods such as [`System.Shell.execute`][shell-execute] to run any command, [`System.Sound.beep`][sound-beep] to be annoying, or [`System.Shell.RecycleBin.emptyAll`][recyclebin-emptyall] to empty the trash;
* Some XHTML elements under the `g` namespace: `g:background`, `g:image` and `g:text`;
* The undocumented `x-gadget:///` protocol gives access to the gadget's files, with special handling for localized files;
* The [documented][gimage] `gimage:///` protocol, a proxy for local image files that can use the Windows thumbnail cache in some cases.
Microsoft published [a security advisory][advisory] encouraging the removal of gadgets from Windows Vista and 7. The "vulnerabilities" are that gadgets can behave like any other program: they can run arbitrary commands and access files. You can do this from any webpage as well, provided you have allowed it to run ActiveX objects. The gadgets documentation has [a whole page on security][sidebar-security] that documents this behavior, takes User Access Control and Parental Controls into account, explains the Internet Explorer settings that could affect gadgets, etc. Gadgets are installed like any other program, and are treated as a program more than a web page. It is very likely that most users would have no idea that those are JavaScript powered. So if Microsoft wanted to remove gadgets because they are programs, why not also remove the ability to execute any program?
Anyway, since gadgets are web pages, it is pretty easy to slap the console in there. The console needed very little modification to work, other than having to force a width and height for the gadget to display correctly. The Vista sidebar limits the console's width, so I added support for the undocked mode, which becomes a "larger size" mode in Windows 7, to allow for a more comfortable console.
## Installation
1. Create a ZIP or CAB file containing all of the files within the `Console.Gadget` directory of this repository.
2. Rename the `.zip` or `.cab` extension to `.gadget`.
3. Open the file in Windows Vista or Windows 7.
4. When the security warning for an unverified publisher appears, click **Install**.
5. ???
6. Profit.
## Screenshot
![The Console as a gadget on Windows 7](./gadget.png)
## Official documentation
* [Windows Sidebar][sidebar-docs]
* [New gadget features in Windows 7][new-win7] (the Sidebar docs do not mention all of the changes)
[advisory]: https://learn.microsoft.com/en-us/security-updates/SecurityAdvisories/2013/2719662
[gimage]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/-sidebar-overview-gdo2#the-gimage-protocol
[new-win7]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/gadgetplatform/introduction-to-the-gadget-platform
[recyclebin-emptyall]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/system-shell-recyclebin-emptyall
[shell-execute]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/system-shell-execute
[sidebar-docs]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/
[sidebar-security]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/-sidebar-gadget-security
[sound-beep]: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/system-sound-beep

BIN
docs/gadget.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB