@radiantabyss/neutralino 1.2.2 → 1.2.4
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/package.json +1 -1
- package/src/Support/Item.js +1 -1
- package/src/SingleInstance.js +0 -56
package/package.json
CHANGED
package/src/Support/Item.js
CHANGED
package/src/SingleInstance.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export default async function() {
|
|
2
|
-
if ( !IS_PACKAGED ) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
let command = `powershell -Command "Get-CimInstance Win32_Process -Filter \"name='${NL_APPID}.exe'\" | Select-Object name"`;
|
|
7
|
-
let result = await Neutralino.os.execCommand(command);
|
|
8
|
-
let regex = new RegExp(`${NL_APPID}\.exe`, 'g');
|
|
9
|
-
let matches = result.stdOut.match(regex);
|
|
10
|
-
|
|
11
|
-
if ( matches && matches.length > 1 ) {
|
|
12
|
-
let command = `powershell -Command "
|
|
13
|
-
Add-Type \"
|
|
14
|
-
using System;
|
|
15
|
-
using System.Runtime.InteropServices;
|
|
16
|
-
|
|
17
|
-
public class WinApi {
|
|
18
|
-
[DllImport(\"user32.dll\")]
|
|
19
|
-
public static extern bool EnumWindows(EnumWindowsProc enum_proc, IntPtr l_param);
|
|
20
|
-
|
|
21
|
-
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
|
22
|
-
|
|
23
|
-
[DllImport(\"user32.dll\")]
|
|
24
|
-
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint process_id);
|
|
25
|
-
|
|
26
|
-
[DllImport(\"user32.dll\")]
|
|
27
|
-
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
|
28
|
-
}
|
|
29
|
-
\";
|
|
30
|
-
$process_name = 'ramp.exe';
|
|
31
|
-
$process_list = Get-CimInstance Win32_Process -Filter \"name='$process_name'\";
|
|
32
|
-
if (-not $process_list) {
|
|
33
|
-
Write-Host \"Process '$process_name' not found.\";
|
|
34
|
-
exit;
|
|
35
|
-
}
|
|
36
|
-
$pids = $process_list.ProcessId;
|
|
37
|
-
$found_windows = @();
|
|
38
|
-
$callback = {
|
|
39
|
-
param($hwnd, $lparam)
|
|
40
|
-
[uint32]$window_pid = 0;
|
|
41
|
-
[WinApi]::GetWindowThreadProcessId($hwnd, [ref]$window_pid);
|
|
42
|
-
if ($pids -contains $window_pid) {
|
|
43
|
-
$script:found_windows += $hwnd;
|
|
44
|
-
}
|
|
45
|
-
return $true;
|
|
46
|
-
};
|
|
47
|
-
[WinApi]::EnumWindows($callback, [IntPtr]::Zero);
|
|
48
|
-
foreach ($hwnd in $found_windows) {
|
|
49
|
-
[WinApi]::ShowWindow($hwnd, 9);
|
|
50
|
-
}
|
|
51
|
-
"`;
|
|
52
|
-
|
|
53
|
-
await Neutralino.os.execCommand(command);
|
|
54
|
-
await Neutralino.app.exit();
|
|
55
|
-
}
|
|
56
|
-
}
|