mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add the web console Notepad and shared skill tables, release v2.10.0
AI Assisted
This commit is contained in:
1 parent
124beb46db
commit
f8b54ef708
59 files changed
+12549
-321
No files matched your search
+35
-11
@@ -216,26 +216,50 @@ public static class Plan2CodeFolderPicker {
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetSystemMetrics(int index);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool IsWindowVisible(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern void SwitchToThisWindow(IntPtr hWnd, bool altTab);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern void keybd_event(byte vk, byte scan, uint flags, UIntPtr extra);
|
||||
|
||||
private const uint FOS_PICKFOLDERS = 0x20;
|
||||
private const uint FOS_FORCEFILESYSTEM = 0x40;
|
||||
private const uint FOS_PATHMUSTEXIST = 0x800;
|
||||
private const uint SIGDN_FILESYSPATH = 0x80058000;
|
||||
private const int ERROR_CANCELLED = unchecked((int)0x800704C7);
|
||||
|
||||
// Windows refuses SetForegroundWindow from a background process (this one is spawned
|
||||
// by the detached console server), so the dialog opened behind the browser. A tap of
|
||||
// Alt counts as input from this process and lifts the lock for the call after it. The
|
||||
// topmost flag below is ignored by this dialog (SetWindowPos succeeds, the bit stays
|
||||
// off), so taking the foreground is what puts it in front.
|
||||
private static void Raise(string title) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
IntPtr hwnd = FindWindow(null, title);
|
||||
if (hwnd != IntPtr.Zero) {
|
||||
int w = Math.Min(1100, GetSystemMetrics(0) - 80);
|
||||
int h = Math.Min(750, GetSystemMetrics(1) - 80);
|
||||
int x = (GetSystemMetrics(0) - w) / 2 + 40;
|
||||
int y = (GetSystemMetrics(1) - h) / 2 + 40;
|
||||
SetWindowPos(hwnd, new IntPtr(-1), x, y, w, h, 0x40);
|
||||
SetForegroundWindow(hwnd);
|
||||
return;
|
||||
}
|
||||
IntPtr hwnd = IntPtr.Zero;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
hwnd = FindWindow(null, title);
|
||||
if (hwnd != IntPtr.Zero && IsWindowVisible(hwnd)) break;
|
||||
hwnd = IntPtr.Zero;
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
if (hwnd == IntPtr.Zero) return;
|
||||
int w = Math.Min(1100, GetSystemMetrics(0) - 80);
|
||||
int h = Math.Min(750, GetSystemMetrics(1) - 80);
|
||||
int x = (GetSystemMetrics(0) - w) / 2 + 40;
|
||||
int y = (GetSystemMetrics(1) - h) / 2 + 40;
|
||||
SetWindowPos(hwnd, new IntPtr(-1), x, y, w, h, 0x40);
|
||||
for (int i = 0; i < 20 && GetForegroundWindow() != hwnd; i++) {
|
||||
keybd_event(0x12, 0, 0, UIntPtr.Zero);
|
||||
keybd_event(0x12, 0, 2, UIntPtr.Zero);
|
||||
SetForegroundWindow(hwnd);
|
||||
SwitchToThisWindow(hwnd, true);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Pick(IntPtr owner, string title, string start) {
|
||||
|
||||
Reference in new issue
Block a user