RequestCapabilities

Requests platform permissions or queries their current state.

This function is exported by the KS module.

Status := RequestCapabilities(Capabilities*)

Parameters

Capabilities

Zero or more capability-name strings. Each string can contain names separated by commas or spaces. If no capability is specified, the function returns the current state of every capability without prompting.

Capability Names

NameAliasesPurpose
InputMonitoringhook, inputhookMonitor keyboard and mouse input, including hotkeys and hotstrings.
InputInjectionsynthinput, sendinputSynthesize keyboard and mouse input with Send, Click and related APIs.
BlockInputSuppress input events.
ScreenCapturecapture, imagecaptureCapture pixels with PixelGetColor, ImageSearch or Image.
AccessibilityAutomationaccessibility, automationAccess accessibility trees, including AT-SPI on Linux.

Names and aliases are case-insensitive.

Return Value

Type: Object

Returns an object with one property per capability. Each value is "Granted", "Denied", "NotApplicable" or "Unsupported". The Granted property is 1 only if every requested capability was granted or is not applicable.

Remarks

On Linux, input-related capabilities and ScreenCapture requested in the same call are batched into one keysharp-inputd prompt.

Use #Requires capability when permissions are needed from startup. Use RequestCapabilities when a script needs to choose when to prompt or inspect individual results.

Examples

#Import "Ks" { RequestCapabilities }
Caps := RequestCapabilities("InputMonitoring", "ScreenCapture")
if Caps.Granted
    MsgBox "All permissions granted"
MsgBox Caps.ScreenCapture

; Query without prompting.
Current := RequestCapabilities()

#Requires capability, Platform Support