]> git.r.bdr.sh - rbdr/captura/blob - Captura/Scripting/RecordCommand.swift
Add AppleScript support
[rbdr/captura] / Captura / Scripting / RecordCommand.swift
1 import Foundation
2
3 @objc(RecordCommand)
4 class RecordCommand: NSScriptCommand {
5 override func performDefaultImplementation() -> Any? {
6 print("AAAH \(self.directParameter)")
7
8 guard let args = self.directParameter as? [String: Any] else {
9 return nil
10 }
11
12 print("AAH COMMANDS \(args)")
13
14 // Here you can extract the parameters from the args dictionary and configure your settings
15 let x = args["x"] as? Int
16 let y = args["y"] as? Int
17 let width = args["width"] as? Int
18 let height = args["height"] as? Int
19 let preventResize = args["prevent_resize"] as? Bool
20 let preventMove = args["prevent_move"] as? Bool
21 let fps = args["fps"] as? Int
22 let outputs = OutputFormatSetting(args["outputs"] as? String ?? "")
23 let backend = URL(string: args["backend"] as? String ?? "")
24 let backendOutput = OutputFormatSetting(args["backend_output"] as? String ?? "")
25 let keepLocalFiles = args["keep_local_files"] as? Bool
26 let autoStart = args["auto_start"] as? Bool
27 let maxLength = args["max_length"] as? Int
28
29 print("AAH WIDTH \(width)")
30
31 var skipBackend = false
32 if let backendString = args["backend"] as? String {
33 if backendString == "" {
34 skipBackend = true
35 }
36 }
37
38 let config = RecordAction(
39 action: "record",
40 x: x,
41 y: y,
42 width: width,
43 height: height,
44 preventResize: preventResize,
45 preventMove: preventMove,
46 fps: fps,
47 outputs: outputs,
48 backend: backend,
49 backendOutput: backendOutput,
50 keepLocalFiles: keepLocalFiles,
51 autoStart: autoStart,
52 skipBackend: skipBackend,
53 maxLength: maxLength
54 )
55
56 NotificationCenter.default.post(name: .setCaptureSessionConfiguration, object: nil, userInfo: [
57 "config": config
58 ])
59 NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil)
60
61 // Return a result if needed
62 return nil
63 }
64 }