Requests platform permissions or queries their current state.
This function is exported by the KS module.
Status := RequestCapabilities(Capabilities*)
Zero or more capability-name strings. Each string can contain names separated by commas or spaces; arrays of names are also accepted. If no capability is specified, the function returns the current state of every capability without prompting.
| Name | Purpose |
|---|---|
InputMonitoring | Observe keyboard/mouse input or poll arbitrary key/button state. Modifier state, lock-toggle state and cursor position are ungated. |
InputControl | Synthesize or suppress keyboard/mouse input, including BlockInput. A suppressing hook requires this and InputMonitoring. |
WindowMonitoring | Query, enumerate, identify or subscribe to events from foreign windows and controls. On macOS it requires Accessibility and Screen Recording permission. |
WindowControl | Activate or mutate foreign windows and controls. Resolving a target can also require WindowMonitoring. |
ScreenCapture | Capture pixels with PixelGetColor, ImageSearch or Image. |
AudioCapture | Reserve permission for audio capture. Audio.Recorder requires it before it opens a device. |
CameraCapture | Reserve permission for camera capture. No current capture API consumes it. |
ClipboardMonitoring | Read or listen to the clipboard. Clipboard writes are ungated. |
The eight canonical names are case-insensitive. Other spellings and aliases are rejected.
Type: Object
Returns an object with one property per capability. Each value is "Granted", "Denied", "NotApplicable" or "Unsupported". The IsGranted property is 1 only if every requested capability was granted or is not applicable.
On Linux, keysharp-input and keysharp-desktop approve their capabilities separately, so one call can show a polkit prompt for each. Grants persist until revoked and are shared by scripts run by the same executable. See Linux permissions.
Use #Requires capability when permissions are needed from startup. Use RequestCapabilities when a script needs to choose when to prompt or inspect individual results.
#Import "Ks" { RequestCapabilities }
Caps := RequestCapabilities("InputMonitoring", "ScreenCapture")
if Caps.IsGranted
MsgBox "All permissions granted"
MsgBox Caps.ScreenCapture
; Query without prompting.
Current := RequestCapabilities()