巨集自動化
52 個節點
本頁內容 52
啟用視窗
函數Brings the window whose title contains this text, ignoring case, to the front and gives it the keyboard - how a macro switches to another program before sending it keys.
啟用視窗(標題: 文字) -> 真否
bool ActivateWindow(string title)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 標題 | 文字 | — | Any part of the title as its title bar reads it: "notepad" finds "Untitled - Notepad". |
返回
| 已啟用 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
點選滑鼠
函數Presses and releases a mouse button where the pointer already is.
點選滑鼠(按鈕: Mouse Button)
void ClickMouse(MacroAutomation.MouseButton button)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 按鈕 | Mouse Button | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
在指定位置點選滑鼠
函數Moves the pointer somewhere and clicks there.
在指定位置點選滑鼠(X: 整數, Y: 整數, 按鈕: Mouse Button)
void ClickMouseAt(
int x,
int y,
MacroAutomation.MouseButton button)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| X | 整數 | — | |
| Y | 整數 | — | |
| 按鈕 | Mouse Button | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
關閉視窗
函數Asks a window to close, as its title bar button does. False where nothing happened; the application may still refuse.
關閉視窗(視窗: Desktop Window) -> 真否
bool CloseWindow(DesktopWindow window)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 視窗 | Desktop Window | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
指揮程序的視窗
函數Applies one command to every window of a named process.
指揮程序的視窗(程序名稱: 文字, 命令: Window Command) -> 整數
int CommandProcessWindows(
string processName,
WindowCommand command)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — | |
| 命令 | Window Command | — |
返回
| 結果 | 整數 |
備註
The count rather than a bool, because "minimise that program" over four windows has three
interesting outcomes and not two: none of them, some of them, all of them.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按兩下滑鼠
函數Presses and releases a button twice where the pointer already is.
按兩下滑鼠(按鈕: Mouse Button)
void DoubleClickMouse(MacroAutomation.MouseButton button)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 按鈕 | Mouse Button | — |
備註
Composed from the primitive rather than asked of the platform. Every platform recognises a
double click from two presses inside its own double-click interval, and two presses sent
back to back are always inside it, so a per-platform double click would be three
implementations of a two-line loop - two of them unrunnable here.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
拖動
函數Presses a button at one point, glides to another, and releases.
拖動
起點 X: 整數
起點 Y: 整數
終點 X: 整數
終點 Y: 整數
按鈕: Mouse Button
時長(毫秒): 整數void Drag(
int fromX,
int fromY,
int toX,
int toY,
MacroAutomation.MouseButton button,
int durationMilliseconds = 300)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 起點 X | 整數 | — | Where the drag starts. |
| 起點 Y | 整數 | — | Where the drag starts. |
| 終點 X | 整數 | — | Where it ends. |
| 終點 Y | 整數 | — | Where it ends. |
| 按鈕 | Mouse Button | — | Which button is held. |
| 時長(毫秒) | 整數 | 300 | Roughly how long the movement between the two takes. |
備註
The package had no drag at all, so its one real caller wrote one: set cursor, button down,
wait 50 ms, set cursor, button up. That works for a list item and fails for anything with a
drag threshold, because the pointer arrives at the destination in a single jump and the
application never sees it move while held.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
沿路徑拖動
函數Presses a button at the first point, glides through every remaining point in order, and releases at the last.
沿路徑拖動
路徑: Screen Point 陣列
按鈕: Mouse Button
時長(毫秒): 整數void DragAlong(
ScreenPoint[] path,
MacroAutomation.MouseButton button,
int durationMilliseconds = 300)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 路徑 | Screen Point 陣列 | — | Two or more points. One point presses and releases without moving; none does nothing. |
| 按鈕 | Mouse Button | — | Which button is held. |
| 時長(毫秒) | 整數 | 300 | Roughly how long the whole path takes, divided between its segments by length. |
備註
The multi-point form exists because the package's only real caller receives a path from a
language model's computer-use reply and used path[0] and path[1], silently
discarding the rest - so a gesture drawn round a corner was delivered as a straight line
through it.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
沿多條路徑拖動
函數Draws a whole pen path: one drag per pen-down..pen-up mark, in order, with the pen lifted between them.
沿多條路徑拖動 -> (已畫標記數: 整數, 已取消: 真否)
標記: IReadOnlyList<Vector2 陣列>
X 偏移: 整數
Y 偏移: 整數
按鈕: Mouse Button
每個標記毫秒數: 整數
標記間隔(毫秒): 整數
取消鍵: Keyint DragAlongPaths(
IReadOnlyList<Vector2[]> marks,
int offsetX,
int offsetY,
MacroAutomation.MouseButton button,
out bool cancelled,
int millisecondsPerMark = 400,
int millisecondsBetweenMarks = 60,
Key cancelKey = Key.None)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 標記 | IReadOnlyList<Vector2 陣列> | — | One mark per entry, each the ordered points of a single stroke, in the drawing's own coordinates with y downwards. This is the shape a traceable font's pen path arrives in; nothing here knows about fonts, and a plotter file or a hand-written list of points serves equally. |
| X 偏移 | 整數 | — | Where the drawing's origin sits on the virtual desktop. |
| Y 偏移 | 整數 | — | Where the drawing's origin sits on the virtual desktop. |
| 按鈕 | Mouse Button | — | Which button is held while a mark is drawn. |
| 每個標記毫秒數 | 整數 | 400 | Roughly how long one mark takes, divided between its segments by length. |
| 標記間隔(毫秒) | 整數 | 60 | How long the pen rests, lifted, between one mark and the next. |
| 取消鍵 | Key | 無 | A key that stops the run. Read between every two steps of the pointer and through every rest, so a tap is noticed whenever it comes; the mark in progress is released where the pointer is, which leaves a shorter stroke and never a line trailing off somewhere else. Key.None means nothing stops it. |
返回
| 已畫標記數 | 整數 |
| 已取消 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
查詢視窗
函數The first window whose title contains this text, or DesktopWindow.None.
查詢視窗(標題片段: 文字) -> Desktop Window
DesktopWindow FindWindow(string titleSubstring)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 標題片段 | 文字 | — |
返回
| 結果 | Desktop Window |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按程序查詢視窗
函數Every window whose owning process has this name, ignoring case and an .exe suffix.
按程序查詢視窗(程序名稱: 文字) -> Desktop Window 陣列
DesktopWindow[] FindWindowsByProcess(string processName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — |
返回
| 結果 | Desktop Window 陣列 |
備註
Above the seam, so "find the window of the program I mean" is written once rather than three
times - two of them on platforms that cannot be run here.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按標題查詢視窗
函數Every window whose title contains this text, ignoring case.
按標題查詢視窗(標題片段: 文字) -> Desktop Window 陣列
DesktopWindow[] FindWindowsByTitle(string titleSubstring)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 標題片段 | 文字 | — |
返回
| 結果 | Desktop Window 陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
聚焦程序
函數Brings a named process's first window to the front.
聚焦程序(程序名稱: 文字) -> 真否
bool FocusProcess(string processName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — |
返回
| 結果 | 真否 |
備註
The first rather than all of them, because focusing several windows in turn leaves whichever
went last in front and is indistinguishable from focusing only that one.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
聚焦視窗
函數Brings a window to the front and gives it the keyboard. False where nothing happened.
聚焦視窗(視窗: Desktop Window) -> 真否
bool FocusWindow(DesktopWindow window)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 視窗 | Desktop Window | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
能否讀取按鍵狀態
函數Whether this machine can be asked what the keyboard is doing, as opposed to only told.
能否讀取按鍵狀態() -> 真否
bool CanReadKeyState()
返回
| 結果 | 真否 |
備註
Separate from MacroAutomation.IsKeyDown because a caller whose stop condition is a key has to be
able to tell "not pressed" from "cannot see the keyboard": a macro that drives the pointer for
minutes and believes the second is the first is a macro nobody can stop. Windows and macOS can;
X11 can when a display opens; nothing else can.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
是否支援
函數False where nothing here can emulate input on this machine; every call is then a no-op.
是否支援() -> 真否
bool IsSupported()
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
平臺名稱
函數A short name for a status line: "Windows", "X11", "Quartz", "none".
平臺名稱() -> 文字
string PlatformName()
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
支援情況
函數How far the backend in force is to be trusted. See DesktopInputEmulation.DesktopInputSupport.
支援情況() -> Desktop Input Support
DesktopInputSupport Support()
返回
| 結果 | Desktop Input Support |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得游標位置
函數Where the pointer is now.
取得游標位置() -> Screen Point
ScreenPoint GetCursor()
返回
| 結果 | Screen Point |
備註
There was no way to ask this before. The Windows file declared GetCursorPos but left it
private and [Obsolete], so no caller could reach it - and the package's one real
caller has a commented-out SetCursor beside the note that the cursor should not be
moved, which is exactly the case a read-back serves: scroll where the pointer already is.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得指定位置的顯示器
函數Which monitor a coordinate is on, or the primary one where it is on none of them.
取得指定位置的顯示器(X: 整數, Y: 整數) -> Display Info
DisplayInfo GetDisplayAt(int x, int y)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| X | 整數 | — | |
| Y | 整數 | — |
返回
| 結果 | Display Info |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得顯示器
函數Every monitor, with its place on the virtual desktop and its scale.
取得顯示器() -> Display Info 陣列
DisplayInfo[] GetDisplays()
返回
| 結果 | Display Info 陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得前臺視窗
函數The window with focus, or DesktopWindow.None where nothing has it.
取得前臺視窗() -> Desktop Window
DesktopWindow GetForegroundWindow()
返回
| 結果 | Desktop Window |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得自身程序名稱
函數This process's own name, so a macro can recognise - and avoid acting on - the windows of the program running it.
取得自身程序名稱() -> 文字
string GetOwnProcessName()
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得有視窗的程序
函數The distinct names of every process that owns a window, for a caller offering a list to choose from.
取得有視窗的程序() -> 文字陣列
string[] GetProcessesWithWindows()
返回
| 結果 | 文字陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得虛擬桌面邊界
函數The rectangle every coordinate in this class lives in: the union of every monitor.
取得虛擬桌面邊界() -> Screen Rectangle
ScreenRectangle GetVirtualDesktopBounds()
返回
| 結果 | Screen Rectangle |
備註
Its origin can be negative. That is the whole reason this is a rectangle and not a size, and
the reason the old SM_CXSCREEN / SM_CYSCREEN normalisation could not reach a
second monitor.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得視窗邊界
函數Where the first window of a named process is, as four numbers, and whether it was found at all.
取得視窗邊界(程序名稱: 文字) -> (已找到: 真否, X: 整數, Y: 整數, 寬度: 整數, 高度: 整數, 最大化: 真否)
bool GetWindowBounds(
string processName,
out int x,
out int y,
out int width,
out int height,
out bool maximized)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — | The owning process, ignoring case and an .exe suffix. |
返回
| 已找到 | 真否 |
| X | 整數 |
| Y | 整數 |
| 寬度 | 整數 |
| 高度 | 整數 |
| 最大化 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得視窗
函數Every top-level window that is on screen and has a title, front-most first where the platform has an order.
取得視窗() -> Desktop Window 陣列
DesktopWindow[] GetWindows()
返回
| 結果 | Desktop Window 陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
取得游標下的視窗
函數The front-most window whose bounds contain the pointer, or DesktopWindow.None.
取得游標下的視窗() -> Desktop Window
DesktopWindow GetWindowUnderCursor()
返回
| 結果 | Desktop Window |
備註
A bounds test over the enumeration, which each backend returns in front-to-back order, so the
first hit is the one a click would land on. It is a bounds test and not a hit test: a click
on a rounded corner or a transparent region of the front window would reach whatever is
behind it, and no platform reports that without asking the window itself.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按鍵是否按下
函數Whether a key is physically down right now, whoever has focus.
按鍵是否按下(鍵: Key) -> 真否
bool IsKeyDown(Key key)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵 | Key | — |
返回
| 結果 | 真否 |
備註
The keyboard's MacroAutomation.GetCursor: this package could drive a keyboard and could not read
one, so a macro had no way to notice a person asking it to stop. It reads the device rather
than a window's message queue, which is what makes it answerable while the process running the
macro is minimised and has no focus - the state such a macro is normally in, since it has just
got out of the way of whatever it is driving.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最大化前臺視窗
函數Maximises the window that currently has focus.
最大化前臺視窗() -> 真否
bool MaximizeForegroundWindow()
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最大化程序視窗
函數Maximises every window of a named process. Returns how many.
最大化程序視窗(程序名稱: 文字) -> 整數
int MaximizeProcessWindows(string processName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最大化視窗
函數Fills the window's monitor with it. False where nothing happened.
最大化視窗(視窗: Desktop Window) -> 真否
bool MaximizeWindow(DesktopWindow window)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 視窗 | Desktop Window | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最小化前臺視窗
函數Iconifies the window that currently has focus.
最小化前臺視窗() -> 真否
bool MinimizeForegroundWindow()
返回
| 結果 | 真否 |
備註
This is what HideEditor did, under a name that says so. The old name described a
caller's intent rather than the operation - it minimised whatever was in front, whether or not
that was an editor - and it was the package's entire window vocabulary.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最小化程序視窗
函數Iconifies every window of a named process. Returns how many.
最小化程序視窗(程序名稱: 文字) -> 整數
int MinimizeProcessWindows(string processName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
最小化視窗
函數Iconifies a window. False where nothing happened.
最小化視窗(視窗: Desktop Window) -> 真否
bool MinimizeWindow(DesktopWindow window)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 視窗 | Desktop Window | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
移動游標
函數Moves the pointer by a delta from wherever it is.
移動游標(X 方向導數階數: 整數, Y 方向導數階數: 整數)
void MoveCursor(int dx, int dy)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| X 方向導數階數 | 整數 | — | |
| Y 方向導數階數 | 整數 | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
平滑移動游標
函數Moves the pointer to an absolute coordinate over time, accelerating and decelerating.
平滑移動游標(X: 整數, Y: 整數, 時長(毫秒): 整數)
void MoveCursorSmoothly(
int x,
int y,
int durationMilliseconds = 250)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| X | 整數 | — | Destination x, in virtual-desktop coordinates. |
| Y | 整數 | — | Destination y. |
| 時長(毫秒) | 整數 | 250 | Roughly how long the movement should take. |
備註
A pointer that teleports is the single most reliable signature of emulated input: some
applications ignore a click whose press arrives in the same input batch as the move that got
there, and hover states, drag thresholds and tooltips never fire at all. The easing is a
smoothstep, so the motion starts and ends slowly, which is also what makes the intermediate
positions land on the widgets a real hand would have crossed.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按鍵
函數Presses and releases a key, optionally holding modifiers while it is pressed.
按鍵(鍵: Key, 修飾鍵: Key Modifiers)
void PressKey(
Key key,
KeyModifiers modifiers = KeyModifiers.None)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵 | Key | — | The key to press. |
| 修飾鍵 | Key Modifiers | 無 | Keys held down for the duration of the press. None by default. |
備註
Modifiers are pressed in a fixed order and released in the reverse of it, so a chord leaves
the keyboard exactly as it found it. Releasing in the same order as pressing is how an
emulated chord leaves a modifier stuck down - the failure the package README already
records as a "weird sticky key issue".
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
按組合鍵
函數Presses a chord given as keys: every key but the last is held, the last is pressed, and the held ones are released in reverse.
按組合鍵(鍵: Key 陣列)
void PressKeyCombination(Key[] keys)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵 | Key 陣列 | — |
備註
This is the shape a language model's computer-use reply arrives in - ["ctrl", "c"] -
and the shape the package could not express. The one real caller looped over the array
calling the old PressKey once per name, which pressed and released Control on its own
and then typed a lower-case "c".
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
還原程序視窗
函數Brings back every minimised window of a named process, each as it was before it was minimised, and leaves its other windows as they are. Returns how many came back.
還原程序視窗(程序名稱: 文字) -> 整數
int RestoreProcessWindows(string processName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 程序名稱 | 文字 | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
還原視窗
函數Puts a minimised or maximised window back to its previous size. False where nothing happened.
還原視窗(視窗: Desktop Window) -> 真否
bool RestoreWindow(DesktopWindow window)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 視窗 | Desktop Window | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
滾動到位置
函數Scrolls vertically. Positive scrolls down, as one detent of a wheel.
滾動到位置(垂直滾動量: 整數)
void ScrollAbsolute(int scrollY)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 垂直滾動量 | 整數 | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
水平滾動
函數Scrolls horizontally. Positive scrolls right.
水平滾動(水平滾動量: 整數)
void ScrollHorizontal(int scrollX)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 水平滾動量 | 整數 | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
傳送文字
函數Types text into whatever has focus, as characters rather than key positions.
傳送文字(文字: 文字, 等待時間(毫秒): 整數)
void SendText(string text, int settleMilliseconds = 0)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to type. |
| 等待時間(毫秒) | 整數 | 0 | How long to wait afterwards. Zero by default. |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
設定游標位置
函數Puts the pointer at an absolute virtual-desktop coordinate, immediately.
設定游標位置(X: 整數, Y: 整數)
void SetCursor(int x, int y)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| X | 整數 | — | |
| Y | 整數 | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
設定按鍵狀態
函數Holds a key down, or lets it up, without the other half.
設定按鍵狀態(鍵: Key, 按下: 真否)
void SetKeyState(Key key, bool pressed)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵 | Key | — | |
| 按下 | 真否 | — |
備註
A caller that takes a key down is responsible for putting it back up. Everything composed in
this class pairs its own presses, which is why nothing here can leave a modifier stuck.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
設定滑鼠狀態
函數Presses or releases a mouse button without releasing it again.
設定滑鼠狀態(按鈕: Mouse Button, 按下: 真否)
void SetMouseState(
MacroAutomation.MouseButton button,
bool pressed)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 按鈕 | Mouse Button | — | |
| 按下 | 真否 | — |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
嘗試啟用按顯示器 DPI 感知
函數Asks Windows to treat this process as per-monitor DPI aware, so the coordinates here are real pixels.
嘗試啟用按顯示器 DPI 感知() -> 真否
bool TryEnablePerMonitorDpiAwareness()
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
嘗試按下指定名稱的鍵
函數Presses a key named as text, including a chord written as one string: "Enter", "esc", "ctrl+c".
嘗試按下指定名稱的鍵(鍵名: 文字) -> 真否
bool TryPressKeyNamed(string keyName)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵名 | 文字 | — |
返回
| 結果 | 真否 |
備註
The string-taking entry point survives, because the caller that needs one receives key names
from a language model and cannot be given an enum. What has gone is the guessing: the old
method parsed, caught whatever the parse threw, prepended VK_ and parsed again, so an
unrecognised name surfaced as an ArgumentException about a key the caller never wrote.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
嘗試按下指定名稱的多個鍵
函數Presses a chord named as separate strings, as ["ctrl", "shift", "n"].
嘗試按下指定名稱的多個鍵(鍵名: 文字陣列) -> 真否
bool TryPressKeysNamed(string[] keyNames)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 鍵名 | 文字陣列 | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
等待
函數Waits, in milliseconds.
等待(毫秒數: 整數)
void Wait(int milliseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 毫秒數 | 整數 | — |
備註
Through the backend rather than straight to Thread.Sleep, so a test that has installed
a DesktopInputEmulation.RecordingDesktopInput can assert what a macro asked to wait for without
spending it. Its default implementation is Thread.Sleep.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化
等待,除非按下某鍵
函數Waits, unless a key goes down first - in which case it stops waiting there and says so.
等待,除非按下某鍵(毫秒數: 整數, 鍵: Key) -> 真否
bool WaitUnlessKeyDown(int milliseconds, Key key)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 毫秒數 | 整數 | — | The longest it waits. |
| 鍵 | Key | — | The key that cuts the wait short, read from the device as MacroAutomation.IsKeyDown reads it. |
返回
| 按鍵按下 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 巨集自動化
- 所屬包
- 桌面自動化