pi-win-notify 1.0.12 → 1.0.14

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.
@@ -6,7 +6,7 @@ function l($m) { try { "$m" | Out-File -Append -Encoding utf8 $log } catch {} }
6
6
 
7
7
  l '[host-start]'
8
8
 
9
- Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase,System.Windows.Forms
9
+ Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase,System.Windows.Forms,System.Drawing
10
10
  l '[host-assemblies-ok]'
11
11
 
12
12
  # PF: 切回终端
@@ -246,15 +246,23 @@ function Show-Notify($data) {
246
246
 
247
247
  $cursor = [System.Windows.Forms.Cursor]::Position
248
248
  $screen = [System.Windows.Forms.Screen]::FromPoint($cursor)
249
- $waL = $screen.WorkingArea.Left
250
- $waT = $screen.WorkingArea.Top
251
- $waW = $screen.WorkingArea.Width
252
- $waH = $screen.WorkingArea.Height
249
+ # WinForms WorkingArea 是物理像素;WPF Window 坐标是设备无关像素 (DIP, 1/96in)。
250
+ # 高分屏 (150%+/200%+) 下必须除以 DPI 缩放比。
251
+ # 注意:PowerShell 宿主中 SystemParameters.DpiX 返回 0,必须用 System.Drawing。
252
+ $gfx = [System.Drawing.Graphics]::FromHwnd([System.IntPtr]::Zero)
253
+ try {
254
+ $dpiScaleX = $gfx.DpiX / 96.0
255
+ $dpiScaleY = $gfx.DpiY / 96.0
256
+ } finally { $gfx.Dispose() }
257
+ $waL = $screen.WorkingArea.Left / $dpiScaleX
258
+ $waT = $screen.WorkingArea.Top / $dpiScaleY
259
+ $waW = $screen.WorkingArea.Width / $dpiScaleX
260
+ $waH = $screen.WorkingArea.Height / $dpiScaleY
253
261
  $count = inc-stack
254
262
  $offset = ($count - 1) * 128
255
263
  $win.Left = $waL + $waW - $win.Width - 20
256
264
  $win.Top = $waT + $waH - $win.Height - 10 - $offset
257
- l "[ps-stack] count=$count offset=$offset"
265
+ l "[ps-stack] count=$count offset=$offset dpiScaleX=$dpiScaleX dpiScaleY=$dpiScaleY"
258
266
 
259
267
  $timer = New-Object System.Windows.Threading.DispatcherTimer
260
268
  $timer.Interval = [TimeSpan]::FromSeconds($timeout)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-win-notify",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "description": "A Windows notification tool for pi — fast focus, response preview, elapsed time, mute, multi-language",
6
6
  "keywords": [
@@ -11,7 +11,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
11
11
  const pkgDir = dirname(__dirname); // pi-win-notify root
12
12
 
13
13
  // Source: where npm hoisted the native module (top-level node_modules)
14
- const src = join(pkgDir, "..", "..", "@koromix", "koffi-win32-x64");
14
+ const src = join(pkgDir, "..", "..", "node_modules", "@koromix", "koffi-win32-x64");
15
15
  // Dest: where koffi expects it (inside pi-win-notify/node_modules)
16
16
  const destDir = join(pkgDir, "node_modules", "@koromix");
17
17
  const dest = join(destDir, "koffi-win32-x64");