<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSScriptCommand/current()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSScriptCommand(cm)currentCommand"
  },
  "title" : "current()"
}
-->

# current()

If a command is being executed in the current thread by Cocoa scripting’s built-in Apple event handling, return the command.

```
class func current() -> NSScriptCommand?
```

## Discussion

A command is being executed in the current thread by Cocoa scripting’s built-in Apple event handling if an instance of `NSScriptCommand` is handling an [`execute()`](/documentation/Foundation/NSScriptCommand/execute()) message at this instant as the result of the dispatch of an Apple event. Returns `nil` otherwise. [`scriptErrorNumber`](/documentation/Foundation/NSScriptCommand/scriptErrorNumber) and [`scriptErrorString`](/documentation/Foundation/NSScriptCommand/scriptErrorString) messages sent to the returned command object will affect the reply event sent to the sender of the event from which the command was constructed, if the sender has requested a reply.

A suspended command is not considered the current command. If a command is suspended and no other command is being executed in the current thread, [`current()`](/documentation/Foundation/NSScriptCommand/current()) returns `nil`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)