Commit 3aba242
* Windows: restore main window after Pick location (#3)
BeginPick minimizes the owner so the user can pick coordinates beneath
the app. Window_StateChanged turns that minimize into Hide(), which
leaves the window with Visibility.Hidden. The pick callbacks only set
WindowState = Normal, which doesn't unhide the window — Activate() on a
hidden window is a no-op too. Result: coordinates were captured but the
app appeared to vanish.
Fix: call Show() in OnLocationPicked and OnPickCancelled, matching what
RestoreFromTray already does.
Fixes #3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Windows: fix WH_MOUSE_LL hMod and add picker diagnostics (#3)
The pick overlay was showing but clicks were never captured. Symptom:
overlay's "Click to select location | ESC to cancel" hint stays on
screen, X/Y boxes are never populated, and the previous OnLocationPicked
restore code never runs (which is why the earlier Show() fix alone did
not help — the callback was never reaching it).
Root cause (likely): SetHook passed
GetModuleHandle(MainModule.ModuleName) — i.e. GetModuleHandle("QuadClicker.exe").
On .NET 10 apphost / single-file deployments the loaded EXE module can
register under a name that does not match Process.MainModule.ModuleName,
so the lookup silently returns 0. SetWindowsHookEx then refuses to
install with hMod=0, returns IntPtr.Zero, and the hook never fires.
Fix: pass NULL for hMod (the Win32-documented form: Windows substitutes
the EXE's HMODULE). Required widening NativeMethods.GetModuleHandle to
accept string?.
Also adds file-based diagnostics at %APPDATA%\QuadClicker\picker.log
covering the BeginPick → ShowOverlay → SetHook → HookCallback → dispatch
chain, plus a visible red error in the overlay when SetHook fails — so
if the picker still misbehaves we have evidence instead of guessing.
Refs #3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Windows: replace broken GetModuleHandle P/Invoke with Marshal.GetHINSTANCE (#3)
Diagnostic log captured the actual root cause:
EntryPointNotFoundException: Unable to find an entry point named
'GetModuleHandle' in DLL 'kernel32.dll'.
kernel32.dll only exports GetModuleHandleA / GetModuleHandleW. The
[DllImport(CharSet=Auto)] convention auto-appended the W suffix, but
the [LibraryImport] source generator does not — even with
StringMarshalling.Utf16 you must set EntryPoint explicitly. Calling
NativeMethods.GetModuleHandle(...) therefore threw at runtime, SetHook
blew up before installing the WH_MOUSE_LL hook (after the overlay had
already been shown), and clicks went nowhere.
Fix: drop the GetModuleHandle P/Invoke entirely and use
Marshal.GetHINSTANCE(typeof(LocationPicker).Module) for hMod. WH_MOUSE_LL
hooks run in the calling thread regardless of hMod, so any valid module
handle works — and this avoids the marshaler edge case entirely.
The diagnostics added in c10a9e8 stay; they are what surfaced this
within one user-test cycle.
Refs #3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dec9f7c commit 3aba242
3 files changed
Lines changed: 60 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | | - | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
53 | 71 | | |
54 | 72 | | |
55 | 73 | | |
| |||
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 80 | + | |
74 | 81 | | |
75 | 82 | | |
76 | 83 | | |
| |||
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
85 | 101 | | |
86 | 102 | | |
87 | 103 | | |
| |||
94 | 110 | | |
95 | 111 | | |
96 | 112 | | |
| 113 | + | |
| 114 | + | |
97 | 115 | | |
98 | 116 | | |
99 | 117 | | |
100 | 118 | | |
101 | 119 | | |
102 | 120 | | |
| 121 | + | |
103 | 122 | | |
104 | 123 | | |
105 | 124 | | |
106 | 125 | | |
| 126 | + | |
107 | 127 | | |
108 | 128 | | |
109 | 129 | | |
| |||
132 | 152 | | |
133 | 153 | | |
134 | 154 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
141 | 179 | | |
142 | 180 | | |
143 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
| 256 | + | |
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
| |||
0 commit comments