跳到主要内容

命名常量

具有一组固定选项的内置函数参数接受来自以下某个命名空间的 Integer。这些名称在脚本编译时会被替换为对应的数字,因此在运行时没有任何开销;输入命名空间和点号后,编辑器会自动完成它们,并显示每个名称的值和含义。它们区分大小写,拼错的名称会导致编译错误。直接写数字也可以(VirtualKey.A 即 65,也即 0x41),但名称能说明其含义。接受整数的步骤字段也接受相同的名称。

命名空间成员 = 值使用者
MouseButtonLeft=0 Right=1 Middle=2 X1=3 X2=4 Primary=5 Secondary=6MouseClick、MouseButtonDown/Up、MouseDoubleClick、MouseIsButtonDown;也是 ContextGetStrokeButton 的返回值(没有按钮上下文时为 -1)。Primary 是 Windows 视为左键单击的按钮,Secondary 是 Windows 视为右键单击的按钮,遵循 Windows 的“主鼠标按钮”设置,因此普通单击或右键单击请使用它们。Left 和 Right 是物理按钮:如果在 Windows 鼠标设置中交换了主按钮和辅助按钮,MouseButton.Left 单击的是物理左键,而 Windows 会将其视为右键单击。ContextGetStrokeButton 以交换后的按钮报告 Primary 或 Secondary,因此无论由哪个物理按钮绘制,右键手势都报告为 Secondary,将该值传给 MouseClick 即可按下同一个按钮。录制的宏使用 Primary 和 Secondary。
FileNotifyFileName=0x1 DirName=0x2 Attributes=0x4 Size=0x8 LastWrite=0x10 LastAccess=0x20 Creation=0x40 Security=0x100FolderWatchCreate 的 filterMask。这些是位标志,因此可以用 | 组合。
AudioEndpointPlayback=0 Capture=1 Communications=2Multimedia* 音量和静音内置函数
WindowStyleNormal=0 Minimized=1 Maximized=2 Hidden=3ShellRunProgram
ShellVerbOpen=0 Edit=1 Print=2 RunAs=3 Properties=4 Explore=5 Find=6ShellRunProgram 的 verb,它也接受以 Text 形式给出的任何其他谓词
LocationTopLeft=0 TopCenter=1 TopRight=2 MiddleLeft=3 MiddleCenter=4 MiddleRight=5 BottomLeft=6 BottomCenter=7 BottomRight=8UIShowDisplayMessage 的 location,它也接受 Text 形式的 "x,y" 屏幕坐标点
TextAlignLeft=0 Center=1 Right=2UIShowDisplayMessage/UIUpdateDisplayMessage
LockResultAcquired=0 TimedOut=1 Pinned=2由 UtilityLockAcquire/UtilityLockAcquirePinned 返回
LockStateFree=0 HeldByMe=1 HeldByOther=2 Pinned=3由 UtilityLockGetState 返回
SerialParityNone=0 Odd=1 Even=2 Mark=3 Space=4SerialOpenPort、SerialMonitorCreate
SerialStopBitsOne=0 OnePointFive=1 Two=2SerialOpenPort、SerialMonitorCreate
DateTimeStyleShortDate=0 LongDate=1 ShortTime=2 LongTime=3 ShortDateTime=4 LongDateTime=5 FileStamp=6DateTimeFormat。除 FileStamp 外,其余各项都遵循用户的 Windows 区域设置,并使用该区域自己的日历;FileStamp 始终为 20261001-140509 这样的格式,可按时间排序,且可安全用于文件名。
DateTimePartYear=0 Month=1 Day=2 Hour=3 Minute=4 Second=5 Weekday=6DateTimeGetPart。公历,本地时间。Weekday 遵循 ISO:1 为星期一,7 为星期日。
VirtualKeyWin32 虚拟键码,按 .NET 的 Keys 枚举命名(见下文)所有接受 Integer key 的 Keyboard* 内置函数

VirtualKey 成员​

Oem* 键按其在美式键盘上产生的符号命名。实际的物理按键因键盘布局而异。

LButton RButton Cancel MButton XButton1 XButton2 Back Tab Clear Enter ShiftKey ControlKey Menu Pause CapsLock Escape Space PageUp PageDown End Home Left Up Right Down Select Print Execute PrintScreen Insert Delete Help D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z LWin RWin Apps Sleep NumPad0 NumPad1 NumPad2 NumPad3 NumPad4 NumPad5 NumPad6 NumPad7 NumPad8 NumPad9 Multiply Add Separator Subtract Decimal Divide F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 NumLock Scroll LShiftKey RShiftKey LControlKey RControlKey LMenu RMenu BrowserBack BrowserForward BrowserRefresh BrowserStop BrowserSearch BrowserFavorites BrowserHome VolumeMute VolumeDown VolumeUp MediaNextTrack MediaPreviousTrack MediaStop MediaPlayPause LaunchMail SelectMedia LaunchApplication1 LaunchApplication2 OemSemicolon Oemplus Oemcomma OemMinus OemPeriod OemQuestion Oemtilde OemOpenBrackets OemPipe OemCloseBrackets OemQuotes Oem8 Oem102

组合键文本(KeyboardPressKeyCombo)​

KeyboardPressKeyCombo 接受 Text,而不是常量:任意数量的修饰键前缀,后跟恰好一个键。每次调用一个组合键,不支持重复次数。键之后不能再有任何内容:"^cx" 或 "Control+V" 是错误,而不会按下第一个键。

前缀^+%@
修饰键CtrlShiftAltWin

键是单个字母或数字(大小写均可),或是以下用大括号括起的名称之一(字母大小写不限):{ENTER} {ESC} {TAB} {DEL} {BS} {SPACE} {HOME} {END} {PGUP} {PGDN} {LEFT} {RIGHT} {UP} {DOWN} {INSERT} {F1}…{F24} {PRTSC} {CAPSLOCK} {NUMLOCK} {SCROLLLOCK} {BREAK} {HELP} {CLEAR} {NUMPAD0}…{NUMPAD9} {MULTIPLY} {ADD} {SEPARATOR} {SUBTRACT} {DECIMAL} {DIVIDE}。{ESCAPE} 和 {DELETE} 同样有效。

示例:"^c" Ctrl+C · "^+{ESC}" Ctrl+Shift+Esc · "%{F4}" Alt+F4 · "@d" Win+D · "^{HOME}" Ctrl+Home · "{enter}" Enter。

熟悉 .NET 的 SendKeys? 前缀和大括号中的名称遵循 Microsoft 的 SendKeys 语法。此文本增加了表示 Windows 键的 @, 以及表示数字小键盘专用键的 {NUMPAD0}…{NUMPAD9}、{SEPARATOR} 和 {DECIMAL}。它不支持重复次数({LEFT 4})、 一个文本中的多个键("^s{ENTER}")、括号分组("+(ec)")、表示 Enter 的 ~、{+} 这类大括号中的字面字符, 以及短名称 {BKSP} 和 {INS}。