<# Get-LogiSwitchReport.ps1 - build a support report you can paste into any Claude chat. The report starts with instructions for Claude, then diagnostics, then the full source code. Removes: Windows username, computer name, Bluetooth/hardware addresses and device serials. Saves to the Desktop, copies to the clipboard and opens it in Notepad. #> param([string]$Problem = '', [switch]$NoOpen, [switch]$NoClipboard, [string]$OutFile) $ErrorActionPreference = 'Continue' $here = Split-Path -Parent $MyInvocation.MyCommand.Path $dataDir = Join-Path $env:LOCALAPPDATA 'LogiSwitch' $psExe = Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe' function Protect-Text([string]$t) { if (-not $t) { return $t } $t = $t -replace [regex]::Escape($env:USERNAME), '' $t = $t -replace [regex]::Escape($env:COMPUTERNAME), '' if ($env:USERDOMAIN) { $t = $t -replace ('\b' + [regex]::Escape($env:USERDOMAIN) + '\b'), '' } $t = $t -replace '(?i)(?' # Bluetooth addresses in device paths $t = $t -replace '(?i)\b([0-9a-f]{2}[:-]){5}[0-9a-f]{2}\b', '' # MAC-style addresses $t = $t -replace '(?i)(serial\w*\s*[=:]\s*"?)[^",\s]+', '$1' $t } function Section($title, $body, [switch]$Raw) { $b = [string]$body; if (-not $Raw) { $b = Protect-Text $b } "`n===== $title =====`n" + $b.TrimEnd() } if (-not $Problem) { try { Add-Type -AssemblyName Microsoft.VisualBasic $Problem = [Microsoft.VisualBasic.Interaction]::InputBox('Briefly describe the problem (what you did, what happened, what you expected):', 'LogiSwitch support report', '') } catch {} } $ver = try { (Get-Content (Join-Path $here 'version.txt') -ErrorAction Stop | Select-Object -First 1).Trim() } catch { '?' } $os = Get-CimInstance Win32_OperatingSystem $sb = New-Object System.Text.StringBuilder [void]$sb.AppendLine(@" ===== INSTRUCTIONS FOR CLAUDE ===== You are helping me fix "LogiSwitch", a small Windows tool (PowerShell 5.1 + embedded C#) that switches my Logitech keyboard and mouse between my Windows PC and my Mac. How it works: - It sends the Logitech HID++ 2.0 "Change Host" command (feature 0x1814, function 1 setCurrentHost, host index 0-based) over the existing USB receiver or Bluetooth HID link. The only network use is the optional clipboard sync (see below). - Bluetooth devices: vendor HID collection usage page 0xFF43 / usage 0x0202, 20-byte long report 0x11, device index 0xFF. Unifying/Bolt receiver: usage page 0xFF00, usage 0x0002 (long) and 0x0001 (short, where receiver errors 0x8F arrive), device index 1-6. - LogiSwitch.ps1 -Watch polls the cursor; when it is held against the outer screen edge facing the Mac (middle 80% of the height, no button held) for ~300 ms it switches all remembered devices to the Mac's channel. The cursor stays on the edge; it re-arms only after the cursor leaves the edge. - Devices are remembered in devices.json; a background runspace re-detects them every 3 minutes. - LogiSwitchTray.ps1 is the icon beside the clock (pause/resume, Mac position, channel, start at login, update, uninstall) and runs the watcher as a hidden child process. - Install-LogiSwitch.ps1 installs per user to %LOCALAPPDATA%\LogiSwitch with a Startup-folder shortcut. No admin rights are available on this PC. Constraints (must keep): - No admin rights, no firewall/security/Group Policy changes, no internet or third-party services, and network only for the optional clipboard sync (off until turned on; the Mac listens on TCP 51888, the PC dials out, AES-256 + HMAC with a shared pairing code), no file sharing. What I need from you: 1. Read my problem description, the diagnostics and the log below, and identify the root cause. 2. Give me the fix: either exact PowerShell commands to run, or the complete corrected file(s) (full file content, ready to save over the old one), then how to reinstall (run Install.cmd from the folder containing the corrected files, or icon menu > Update). 3. Tell me how to confirm it is fixed. If you can run commands on this PC (for example Claude Code), apply the fix yourself instead: the installed files are in %LOCALAPPDATA%\LogiSwitch (it is also a complete install package), reinstall with powershell -NoProfile -ExecutionPolicy Bypass -File "%LOCALAPPDATA%\LogiSwitch\Install-LogiSwitch.ps1" after editing, then verify with ...\LogiSwitch.ps1 -List and the log. The latest automatic report is always at %LOCALAPPDATA%\LogiSwitch\last-problem-report.txt. "@) [void]$sb.AppendLine((Section 'MY PROBLEM' $(if ($Problem) { $Problem } else { '(not described)' }))) $diag = @( "Report created : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" "LogiSwitch : $ver (installed in %LOCALAPPDATA%\LogiSwitch: $(Test-Path (Join-Path $dataDir 'LogiSwitchTray.ps1')))" "Windows : $($os.Caption) $($os.Version)" "PowerShell : $($PSVersionTable.PSVersion) language mode: $($ExecutionContext.SessionState.LanguageMode)" "Exec policy : " + ((Get-ExecutionPolicy -List | ForEach-Object { "$($_.Scope)=$($_.ExecutionPolicy)" }) -join ', ') "Startup entry : $(Test-Path (Join-Path ([Environment]::GetFolderPath('Startup')) 'LogiSwitch.lnk'))" ) -join "`n" [void]$sb.AppendLine((Section 'SYSTEM' $diag)) $procs = Get-CimInstance Win32_Process -Filter "Name='powershell.exe'" | Where-Object { $_.CommandLine -match '\\LogiSwitch(Tray)?\.ps1' } | ForEach-Object { "pid $($_.ProcessId) started $($_.CreationDate): " + ($_.CommandLine -replace '^.*?-File\s+', '-File ') } [void]$sb.AppendLine((Section 'RUNNING PROCESSES' $(if ($procs) { $procs -join "`n" } else { 'none (tray and watcher are not running)' }))) $settings = try { Get-Content (Join-Path $dataDir 'settings.json') -Raw -ErrorAction Stop } catch { '(no settings.json)' } [void]$sb.AppendLine((Section 'SETTINGS (settings.json)' $settings)) $devs = try { $saved = Get-Content (Join-Path $dataDir 'devices.json') -Raw -ErrorAction Stop | ConvertFrom-Json $saved | ForEach-Object { "$($_.Name) | $($_.Transport) | devIdx $($_.DevIdx) | featureIdx $($_.ChangeHostIdx) | channels $($_.HostCount)" } } catch { @('(no devices.json)') } [void]$sb.AppendLine((Section 'REMEMBERED DEVICES (devices.json)' ($devs -join "`n"))) $screens = try { Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { "$($_.DeviceName -replace '^\\\\\.\\','') primary=$($_.Primary) bounds=$($_.Bounds)" } } catch { @('?') } [void]$sb.AppendLine((Section 'DISPLAYS' ($screens -join "`n"))) # Live detection (read-only; takes ~10 s). Runs in a separate process so a hang cannot block the report. $live = '(skipped: LogiSwitch.ps1 not found)' $switchPs1 = Join-Path $here 'LogiSwitch.ps1' if (Test-Path $switchPs1) { $tmp = Join-Path $env:TEMP 'logiswitch-list.txt' $p = Start-Process -FilePath $psExe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$switchPs1`" -List" -RedirectStandardOutput $tmp -WindowStyle Hidden -PassThru if ($p.WaitForExit(45000)) { $live = Get-Content $tmp -Raw } else { try { $p.Kill() } catch {}; $live = '(timed out after 45 s)' } Remove-Item $tmp -ErrorAction SilentlyContinue } [void]$sb.AppendLine((Section 'LIVE DEVICE CHECK (LogiSwitch.ps1 -List, read-only)' $live)) $logi = Get-PnpDevice -PresentOnly -ErrorAction SilentlyContinue | Where-Object { $_.FriendlyName -match 'Logi|MX |ERGO|K860|Bolt|Unifying' -or $_.InstanceId -match 'VID_046D|VID&02046D' } | Sort-Object FriendlyName -Unique | ForEach-Object { "$($_.Status) $($_.Class) $($_.FriendlyName)" } [void]$sb.AppendLine((Section 'LOGITECH DEVICES SEEN BY WINDOWS' ($logi -join "`n"))) $log = try { (Get-Content (Join-Path $dataDir 'watch.log') -Tail 150 -ErrorAction Stop) -join "`n" } catch { '(no watch.log)' } [void]$sb.AppendLine((Section 'LOG (last 150 lines of watch.log)' $log)) foreach ($f in 'LogiSwitch.ps1', 'LogiSwitchTray.ps1', 'Install-LogiSwitch.ps1', 'Uninstall-LogiSwitch.ps1') { $path = Join-Path $here $f $body = if (Test-Path $path) { Get-Content $path -Raw } else { '(missing)' } [void]$sb.AppendLine((Section "SOURCE: $f" $body -Raw)) } [void]$sb.AppendLine("`n===== END OF REPORT =====") $out = if ($OutFile) { $OutFile } else { Join-Path ([Environment]::GetFolderPath('Desktop')) ("LogiSwitch-report-{0:yyyyMMdd-HHmm}.txt" -f (Get-Date)) } $sb.ToString() | Set-Content -Path $out -Encoding utf8 if (-not $NoClipboard) { try { Set-Clipboard -Value $sb.ToString() } catch {} } if (-not $NoOpen) { Start-Process notepad.exe -ArgumentList "`"$out`"" } "Report saved to $out" + $(if ($NoClipboard) { '.' } else { ' (also copied to the clipboard).' })