dsh-plugin-admin 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bring-explorer.ps1 +38 -12
- package/package.json +1 -1
package/lib/bring-explorer.ps1
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# dsh-plugin-admin: bring Explorer window to foreground
|
|
2
2
|
# Usage: powershell -File bring-explorer.ps1 -Path <absolute path>
|
|
3
|
-
|
|
3
|
+
# Fail-soft contract: never waits on user input -- an empty/missing -Path
|
|
4
|
+
# must NOT hit a Mandatory prompt (this console is HIDDEN; the process
|
|
5
|
+
# would linger forever), so the parameter is optional and guarded below.
|
|
6
|
+
param([string]$Path = '')
|
|
7
|
+
|
|
8
|
+
$ErrorActionPreference = 'SilentlyContinue'
|
|
9
|
+
if ([string]::IsNullOrWhiteSpace($Path)) { exit 0 }
|
|
4
10
|
|
|
5
11
|
Add-Type @"
|
|
6
12
|
using System;
|
|
@@ -18,8 +24,24 @@ public class Fr {
|
|
|
18
24
|
}
|
|
19
25
|
"@
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
# The title Explorer displays is the DISPLAY NAME of the revealed FOLDER:
|
|
28
|
+
# the folder itself -- or its PARENT when reveal ran `/select,<file>` on a
|
|
29
|
+
# file. Fall back to the last path segment when the item is gone/unreadable.
|
|
30
|
+
$base = $null
|
|
31
|
+
$item = Get-Item -LiteralPath $Path
|
|
32
|
+
if ($null -ne $item) {
|
|
33
|
+
if ($item.PSIsContainer) { $base = $item.Name }
|
|
34
|
+
else { $base = Split-Path -Leaf $item.DirectoryName }
|
|
35
|
+
} else {
|
|
36
|
+
$segments = ($Path -replace '\\', '/').Split('/') | Where-Object { $_ }
|
|
37
|
+
if ($segments.Count -gt 0) { $base = $segments[-1] }
|
|
38
|
+
}
|
|
39
|
+
if ([string]::IsNullOrWhiteSpace($base)) { exit 0 }
|
|
40
|
+
|
|
41
|
+
# Stock Windows 10/11 titles are the bare folder name; some shell addons
|
|
42
|
+
# append " - <suffix>". Anchor at start, make the dash clause optional so
|
|
43
|
+
# both shapes match, and prefix collisions ("Test" vs "Test 2") stay safe.
|
|
44
|
+
$script:pattern = '^' + [regex]::Escape($base) + '(?:\s*-|$)'
|
|
23
45
|
$script:found = [IntPtr]::Zero
|
|
24
46
|
|
|
25
47
|
function Find-Target {
|
|
@@ -45,12 +67,16 @@ for ($i = 0; $i -lt 30; $i++) {
|
|
|
45
67
|
Start-Sleep -Milliseconds 200
|
|
46
68
|
}
|
|
47
69
|
|
|
48
|
-
if ($target -
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
if ($target -eq [IntPtr]::Zero) { exit 1 }
|
|
71
|
+
|
|
72
|
+
# Simulated ALT keypress grants foreground permission
|
|
73
|
+
[Fr]::keybd_event(0x12, 0, 0, [UIntPtr]::Zero)
|
|
74
|
+
[Fr]::keybd_event(0x12, 0, 2, [UIntPtr]::Zero)
|
|
75
|
+
Start-Sleep -Milliseconds 80
|
|
76
|
+
[Fr]::ShowWindow($target, 9) | Out-Null
|
|
77
|
+
[Fr]::SetForegroundWindow($target) | Out-Null
|
|
78
|
+
[Fr]::BringWindowToTop($target) | Out-Null
|
|
79
|
+
|
|
80
|
+
# One debuggable line on stdout; the host pipe just drains it.
|
|
81
|
+
Write-Output ("raised:{0}" -f $target)
|
|
82
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-admin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "dsh web UI plugin: unified administration panel — plugin and session management with modern tabbed Web UI (host remote + browser panel)",
|
|
6
6
|
"main": "lib/index.js",
|