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. If no capability is specified, the function returns the current state of every capability without prompting.
| Name | Aliases | Purpose |
|---|---|---|
InputMonitoring | hook, inputhook | Monitor keyboard and mouse input, including hotkeys and hotstrings. |
InputInjection | synthinput, sendinput | Synthesize keyboard and mouse input with Send, Click and related APIs. |
BlockInput | Suppress input events. | |
ScreenCapture | capture, imagecapture | Capture pixels with PixelGetColor, ImageSearch or Image. |
AccessibilityAutomation | accessibility, automation | Access accessibility trees, including AT-SPI on Linux. |
Names and aliases are case-insensitive.
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.
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.
#Import "Ks" { RequestCapabilities }
Caps := RequestCapabilities("InputMonitoring", "ScreenCapture")
if Caps.Granted
MsgBox "All permissions granted"
MsgBox Caps.ScreenCapture
; Query without prompting.
Current := RequestCapabilities()