更新
This commit is contained in:
@@ -3,6 +3,8 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Windows;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
@@ -196,9 +198,6 @@ public class KeyIntPtrHelper
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
|
||||
|
||||
/// <summary>
|
||||
/// 显示窗口
|
||||
/// </summary>
|
||||
@@ -218,18 +217,6 @@ public class KeyIntPtrHelper
|
||||
int wFlags
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// 执行Esc两次,退出Revit选择
|
||||
/// </summary>
|
||||
public static void RaiseEscTwice()
|
||||
{
|
||||
SetForegroundWindow(ComponentManager.ApplicationWindow);
|
||||
keybdEvent(27, 0, 0, 0);
|
||||
keybdEvent(27, 0, 2, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找内容
|
||||
/// </summary>
|
||||
@@ -335,6 +322,29 @@ public class KeyIntPtrHelper
|
||||
PostMessage(handle, (uint)KeyboardMsg.WmKeyup, letter, keyUpCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行Esc两次,退出Revit选择
|
||||
/// </summary>
|
||||
public static void RaiseEscTwice()
|
||||
{
|
||||
SetForegroundWindow(ComponentManager.ApplicationWindow);
|
||||
keybdEvent(27, 0, 0, 0);
|
||||
keybdEvent(27, 0, 2, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行Esc两次,退出Revit命令(常用)
|
||||
/// </summary>
|
||||
public static void PostEscTwice()
|
||||
{
|
||||
SetForegroundWindow(ComponentManager.ApplicationWindow);
|
||||
PostMessage(ComponentManager.ApplicationWindow, (uint)KEYBOARD_MSG.WM_KEYDOWN, (uint)27, 0);
|
||||
PostMessage(ComponentManager.ApplicationWindow, (uint)KEYBOARD_MSG.WM_KEYDOWN, (uint)27, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
//keybdEvent(0x1B, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static bool RestoreWindow(IntPtr hWnd)
|
||||
{
|
||||
return ShowWindow(hWnd, 1);
|
||||
@@ -352,11 +362,15 @@ public class KeyIntPtrHelper
|
||||
keybdEvent(bVk, 0, 2, 0);
|
||||
}
|
||||
|
||||
|
||||
public static void SetAsOwner(IntPtr mainHandler, Window childWindow)
|
||||
{
|
||||
new WindowInteropHelper(childWindow).Owner = mainHandler;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
|
||||
|
||||
public static void ShowAndActive(string winname)
|
||||
{
|
||||
var parenthWndldsl = FindWindow(null, winname);
|
||||
@@ -367,6 +381,26 @@ public class KeyIntPtrHelper
|
||||
}
|
||||
}
|
||||
|
||||
private enum WH_KEYBOARD_LPARAM : uint
|
||||
{
|
||||
KEYDOWN = 0x00000001,
|
||||
KEYUP = 0xC0000001
|
||||
}
|
||||
|
||||
public enum KEYBOARD_MSG : uint
|
||||
{
|
||||
WM_KEYDOWN = 0x100,
|
||||
WM_KEYUP = 0x101
|
||||
}
|
||||
|
||||
private enum MVK_MAP_TYPE : uint
|
||||
{
|
||||
VKEY_TO_SCANCODE = 0,
|
||||
SCANCODE_TO_VKEY = 1,
|
||||
VKEY_TO_CHAR = 2,
|
||||
SCANCODE_TO_LR_VKEY = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 键盘消息
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user